- diff --git a/daemon/acl.c b/daemon/acl.c
- index 1d1eac4..9c30eeb 100644
- --- a/daemon/acl.c
- +++ b/daemon/acl.c
- @@ -223,6 +223,19 @@ static int map_name_2_sid(nfs41_daemon_globals *nfs41dg, int query, DWORD *sid_l
- name = "roland_mainz";
- dprintf(ACLLVL, "map_name_2_sid: remap 1616 --> roland_mainz\n");
- }
- + else if (!strcmp(name, "swulsch")) {
- + name = "siegfried_wulsch";
- + dprintf(ACLLVL, "map_name_2_sid: remap swulsch --> siegfried_wulsch\n");
- + }
- + else if (!strcmp(name, "197609")) {
- + name = "siegfried_wulsch";
- + dprintf(ACLLVL, "map_name_2_sid: remap 197609 --> siegfried_wulsch\n");
- + }
- + else if (!strcmp(name, "1818")) {
- + name = "siegfried_wulsch";
- + dprintf(ACLLVL, "map_name_2_sid: remap 1818 --> siegfried_wulsch\n");
- + }
- +
- }
- #endif /* NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID */
- diff --git a/daemon/daemon_debug.h b/daemon/daemon_debug.h
- index f484d58..17cf046 100644
- --- a/daemon/daemon_debug.h
- +++ b/daemon/daemon_debug.h
- @@ -34,6 +34,15 @@
- #define DEFAULT_DEBUG_LEVEL 1
- +#define EASSERT(exp) \
- + if (!(exp)) { \
- + eprintf("ASSERTION '%s' in '%s'/%ld failed.\n", \
- + ""#exp"", __FILE__, (long)__LINE__); }
- +#define DASSERT(exp, level) \
- + if (!(exp)) { \
- + dprintf((level), "ASSERTION '%s' in '%s'/%ld failed.\n", \
- + ""#exp"", __FILE__, (long)__LINE__); }
- +
- /* daemon_debug.h */
- void set_debug_level(int level);
- void dprintf(int level, LPCSTR format, ...);
- diff --git a/daemon/lookup.c b/daemon/lookup.c
- index ea0a9d2..b90c3bd 100644
- --- a/daemon/lookup.c
- +++ b/daemon/lookup.c
- @@ -85,7 +85,8 @@ static void init_component_args(
- args->attr_request.arr[1] = FATTR4_WORD1_MODE
- | FATTR4_WORD1_NUMLINKS | FATTR4_WORD1_SYSTEM
- | FATTR4_WORD1_TIME_ACCESS | FATTR4_WORD1_TIME_CREATE
- - | FATTR4_WORD1_TIME_MODIFY;
- + | FATTR4_WORD1_TIME_MODIFY
- + | FATTR4_WORD1_OWNER | FATTR4_WORD1_OWNER_GROUP;
- args->getrootattr.attr_request = &args->attr_request;
- res->root.path = path;
- @@ -210,8 +211,9 @@ static int server_lookup(
- if (count == 0) {
- if (target_out)
- *target_out = dir;
- - if (info_out)
- - memcpy(info_out, res->getrootattr.info, sizeof(nfs41_file_info));
- + if (info_out) {
- + nfs41_file_info_cpy(info_out, res->getrootattr.info);
- + }
- } else if (count == 1) {
- if (parent_out)
- *parent_out = dir;
- @@ -258,8 +260,9 @@ static int server_lookup(
- if (i == count-1) {
- if (target_out)
- *target_out = file;
- - if (info_out)
- - memcpy(info_out, res->getattr[i].info, sizeof(nfs41_file_info));
- + if (info_out) {
- + nfs41_file_info_cpy(info_out, res->getattr[i].info);
- + }
- } else if (i == count-2) {
- if (parent_out)
- *parent_out = file;
- diff --git a/daemon/name_cache.c b/daemon/name_cache.c
- index eaa0f36..89879a7 100644
- --- a/daemon/name_cache.c
- +++ b/daemon/name_cache.c
- @@ -99,6 +99,8 @@ struct attr_cache_entry {
- unsigned type : 4;
- unsigned invalidated : 1;
- unsigned delegated : 1;
- + char owner[NFS4_OPAQUE_LIMIT+1];
- + char owner_group[NFS4_OPAQUE_LIMIT+1];
- };
- #define ATTR_ENTRY_SIZE sizeof(struct attr_cache_entry)
- @@ -304,6 +306,14 @@ static void attr_cache_update(
- if (info->attrmask.count >= 2) {
- if (info->attrmask.arr[1] & FATTR4_WORD1_MODE)
- entry->mode = info->mode;
- + if (info->attrmask.arr[1] & FATTR4_WORD1_OWNER) {
- + EASSERT(info->owner != NULL);
- + (void)strcpy(entry->owner, info->owner);
- + }
- + if (info->attrmask.arr[1] & FATTR4_WORD1_OWNER_GROUP) {
- + EASSERT(info->owner_group != NULL);
- + (void)strcpy(entry->owner_group, info->owner_group);
- + }
- if (info->attrmask.arr[1] & FATTR4_WORD1_NUMLINKS)
- entry->numlinks = info->numlinks;
- if (info->attrmask.arr[1] & FATTR4_WORD1_TIME_ACCESS) {
- @@ -341,6 +351,12 @@ static void copy_attrs(
- dst->type = src->type;
- dst->numlinks = src->numlinks;
- dst->mode = src->mode;
- + EASSERT(src->owner != NULL);
- + dst->owner = dst->owner_buf;
- + (void)strcpy(dst->owner, src->owner);
- + EASSERT(src->owner_group != NULL);
- + dst->owner_group = dst->owner_group_buf;
- + (void)strcpy(dst->owner_group, src->owner_group);
- dst->fileid = src->fileid;
- dst->hidden = src->hidden;
- dst->system = src->system;
- @@ -353,7 +369,8 @@ static void copy_attrs(
- dst->attrmask.arr[1] = FATTR4_WORD1_MODE
- | FATTR4_WORD1_NUMLINKS | FATTR4_WORD1_TIME_ACCESS
- | FATTR4_WORD1_TIME_CREATE | FATTR4_WORD1_TIME_MODIFY
- - | FATTR4_WORD1_SYSTEM;
- + | FATTR4_WORD1_SYSTEM
- + | FATTR4_WORD1_OWNER | FATTR4_WORD1_OWNER_GROUP;
- }
- diff --git a/daemon/nfs41_daemon.c b/daemon/nfs41_daemon.c
- index 42bfc6c..dcb509e 100644
- --- a/daemon/nfs41_daemon.c
- +++ b/daemon/nfs41_daemon.c
- @@ -402,6 +402,7 @@ VOID ServiceStart(DWORD argc, LPTSTR *argv)
- #ifdef NFS41_DRIVER_FEATURE_NAMESERVICE_CYGWIN
- /* force enable for cygwin getent passwd/group testing */
- cmd_args.ldap_enable = TRUE;
- + DASSERT(0/* test asserts*/, 0);
- #endif /* NFS41_DRIVER_FEATURE_NAMESERVICE_CYGWIN */
- nfs41_server_list_init();
- diff --git a/daemon/nfs41_types.h b/daemon/nfs41_types.h
- index c5bad79..18a763a 100644
- --- a/daemon/nfs41_types.h
- +++ b/daemon/nfs41_types.h
- @@ -236,6 +236,10 @@ typedef struct __nfs41_file_info {
- char *owner;
- char *owner_group;
- uint32_t aclsupport;
- +
- + /* Buffers */
- + char owner_buf[NFS4_OPAQUE_LIMIT+1];
- + char owner_group_buf[NFS4_OPAQUE_LIMIT+1];
- } nfs41_file_info;
- #endif /* !__NFS41_DAEMON_TYPES_H__ */
- diff --git a/daemon/nfs41_xdr.c b/daemon/nfs41_xdr.c
- index 176b613..0261c54 100644
- --- a/daemon/nfs41_xdr.c
- +++ b/daemon/nfs41_xdr.c
- @@ -1802,19 +1802,33 @@ static bool_t decode_file_attrs(
- return FALSE;
- }
- if (attrs->attrmask.arr[1] & FATTR4_WORD1_OWNER) {
- - char *ptr = &info->owner[0];
- + if (info->owner == NULL)
- + info->owner = info->owner_buf;
- +
- + char *ptr = info->owner;
- uint32_t owner_len;
- if (!xdr_bytes(xdr, &ptr, &owner_len,
- - NFS4_OPAQUE_LIMIT))
- + NFS4_OPAQUE_LIMIT)) {
- + info->owner = NULL;
- return FALSE;
- + }
- + EASSERT(owner_len > 0);
- + EASSERT(owner_len < sizeof(info->owner_group_buf));
- info->owner[owner_len] = '\0';
- }
- if (attrs->attrmask.arr[1] & FATTR4_WORD1_OWNER_GROUP) {
- - char *ptr = &info->owner_group[0];
- + if (info->owner_group == NULL)
- + info->owner_group = info->owner_group_buf;
- +
- + char *ptr = info->owner_group;
- uint32_t owner_group_len;
- if (!xdr_bytes(xdr, &ptr, &owner_group_len,
- - NFS4_OPAQUE_LIMIT))
- + NFS4_OPAQUE_LIMIT)) {
- + info->owner_group = NULL;
- return FALSE;
- + }
- + EASSERT(owner_group_len > 0);
- + EASSERT(owner_group_len < sizeof(info->owner_group_buf));
- info->owner_group[owner_group_len] = '\0';
- }
- if (attrs->attrmask.arr[1] & FATTR4_WORD1_SPACE_AVAIL) {
- diff --git a/daemon/open.c b/daemon/open.c
- index 13e82b2..36f2fb2 100644
- --- a/daemon/open.c
- +++ b/daemon/open.c
- @@ -629,7 +629,7 @@ static int handle_open(void *daemon_context, nfs41_upcall *upcall)
- status = NO_ERROR;
- } else if (args->symlink.len) {
- /* handle cygwin symlinks */
- - nfs41_file_info createattrs;
- + nfs41_file_info createattrs = { 0 };
- createattrs.attrmask.count = 2;
- createattrs.attrmask.arr[0] = 0;
- createattrs.attrmask.arr[1] = FATTR4_WORD1_MODE;
- @@ -663,33 +663,22 @@ static int handle_open(void *daemon_context, nfs41_upcall *upcall)
- args->changeattr = info.change;
- #ifdef NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES
- - bitmap4 og_attr_request = { 0 };
- - nfs41_file_info og_info = { 0 };
- - char owner[NFS4_OPAQUE_LIMIT], group[NFS4_OPAQUE_LIMIT];
- - nfsacl41 acl = { 0 };
- -
- - /*
- - * gisburn:
- - * 1. We should cache owner/group information
- - * 2. We should always ask for
- - * FATTR4_WORD1_OWNER | FATTR4_WORD1_OWNER_GROUP with the other
- - * attributes
- - */
- - og_attr_request.count = 2;
- - og_attr_request.arr[1] = FATTR4_WORD1_OWNER | FATTR4_WORD1_OWNER_GROUP;
- - og_info.owner = owner;
- - og_info.owner_group = group;
- - status = nfs41_getattr(state->session, &state->file, &og_attr_request, &og_info);
- - if (status) {
- - eprintf("get_stat_data: nfs41_cached_getattr() failed with %d\n",
- - status);
- - }
- -
- + char owner[NFS4_OPAQUE_LIMIT], owner_group[NFS4_OPAQUE_LIMIT];
- uid_t map_uid = -1;
- gid_t gid_dummy = -1;
- gid_t map_gid = -1;
- char *at_ch; /* pointer to '@' */
- + EASSERT((info.attrmask.arr[1] & FATTR4_WORD1_OWNER) != 0);
- + EASSERT((info.attrmask.arr[1] & FATTR4_WORD1_OWNER_GROUP) != 0);
- + EASSERT(info.owner != NULL);
- + EASSERT(info.owner_group != NULL);
- + EASSERT(info.owner == info.owner_buf);
- + EASSERT(info.owner_group == info.owner_group_buf);
- + /* Make copies as we will modify them */
- + (void)strcpy(owner, info.owner);
- + (void)strcpy(owner_group, info.owner_group);
- +
- /*
- * Map owner to local uid
- *
- @@ -697,12 +686,12 @@ static int handle_open(void *daemon_context, nfs41_upcall *upcall)
- * ("gisburn") or username@domain ("gisburn@sun.com")
- */
- /* stomp over '@' */
- - if (at_ch = strchr(og_info.owner, '@'))
- + if (at_ch = strchr(owner, '@'))
- *at_ch = '\0';
- if (nfs41_idmap_name_to_ids(
- nfs41dg->idmapper,
- - og_info.owner,
- + owner,
- &map_uid,
- &gid_dummy) == 0) {
- args->owner_local_uid = map_uid;
- @@ -711,7 +700,7 @@ static int handle_open(void *daemon_context, nfs41_upcall *upcall)
- args->owner_local_uid = NFS_USER_NOBODY_UID;
- eprintf("get_stat_data: "
- "no username mapping for '%s', fake uid=%d\n",
- - og_info.owner, args->owner_local_uid);
- + owner, args->owner_local_uid);
- }
- /*
- @@ -721,12 +710,12 @@ static int handle_open(void *daemon_context, nfs41_upcall *upcall)
- * ("gisgrp") or username@domain ("gisgrp@sun.com")
- */
- /* stomp over '@' */
- - if (at_ch = strchr(og_info.owner_group, '@'))
- + if (at_ch = strchr(owner_group, '@'))
- *at_ch = '\0';
- if (nfs41_idmap_group_to_gid(
- nfs41dg->idmapper,
- - og_info.owner_group,
- + owner_group,
- &map_gid) == 0) {
- args->owner_group_local_gid = map_gid;
- }
- @@ -734,12 +723,12 @@ static int handle_open(void *daemon_context, nfs41_upcall *upcall)
- args->owner_group_local_gid = NFS_GROUP_NOGROUP_GID;
- eprintf("get_stat_data: "
- "no group mapping for '%s', fake gid=%d\n",
- - og_info.owner_group, args->owner_group_local_gid);
- + owner_group, args->owner_group_local_gid);
- }
- dprintf(1, "handle_open: stat: owner=%u/'%s', owner_group=%u/'%s'\n",
- - (unsigned int)args->owner_local_uid, og_info.owner,
- - (unsigned int)args->owner_group_local_gid, og_info.owner_group);
- + (unsigned int)args->owner_local_uid, owner,
- + (unsigned int)args->owner_group_local_gid, owner_group);
- #endif /* NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES */
- } else {
- nfs41_file_info createattrs = { 0 };
- diff --git a/daemon/util.c b/daemon/util.c
- index 35cfc5b..0b8cedf 100644
- --- a/daemon/util.c
- +++ b/daemon/util.c
- @@ -201,6 +201,16 @@ void nfs_to_network_openinfo(
- net_out->FileAttributes = nfs_file_info_to_attributes(info);
- }
- +/* copy |nfs41_file_info| */
- +void nfs41_file_info_cpy(
- + OUT nfs41_file_info *dest,
- + IN const nfs41_file_info *src)
- +{
- + (void)memcpy(dest, src, sizeof(nfs41_file_info));
- + dest->owner = dest->owner_buf;
- + dest->owner_group = dest->owner_group_buf;
- +}
- +
- void get_file_time(
- OUT PLARGE_INTEGER file_time)
- {
- diff --git a/daemon/util.h b/daemon/util.h
- index fa0d32c..c4bc886 100644
- --- a/daemon/util.h
- +++ b/daemon/util.h
- @@ -106,6 +106,9 @@ void nfs_to_standard_info(
- void nfs_to_network_openinfo(
- IN const nfs41_file_info *info,
- OUT PFILE_NETWORK_OPEN_INFORMATION std_out);
- +void nfs41_file_info_cpy(
- + OUT nfs41_file_info *dest,
- + IN const nfs41_file_info *src);
- /* http://msdn.microsoft.com/en-us/library/ms724290%28VS.85%29.aspx:
- * A file time is a 64-bit value that represents the number of
- diff --git a/sys/nfs41_build_features.h b/sys/nfs41_build_features.h
- index 93ee7a9..d43334a 100644
- --- a/sys/nfs41_build_features.h
- +++ b/sys/nfs41_build_features.h
- @@ -32,19 +32,19 @@
- /*
- * NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES - return local uid/gid values
- */
- -// #define NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES 1
- +#define NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES 1
- /*
- * NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID - give NFS
- * files which do not map to a local account a SID in the
- * Unix_User+x/Unix_Group+x range
- */
- -// #define NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID 1
- +#define NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID 1
- /*
- * NFS41_DRIVER_FEATURE_NAMESERVICE_CYGWIN - use Cygwin /usr/bin/getent
- * as "name service"
- */
- -// #define NFS41_DRIVER_FEATURE_NAMESERVICE_CYGWIN 1
- +#define NFS41_DRIVER_FEATURE_NAMESERVICE_CYGWIN 1
- #endif /* !_NFS41_DRIVER_BUILDFEATURES_ */
msnfs41client: owner/group name caching prototype
Posted by Anonymous on Fri 20th Oct 2023 14:23
raw | new post
modification of post by Anonymous (view diff)
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.