- diff --git a/daemon/acl.c b/daemon/acl.c
- index 1d1eac4..4297722 100644
- --- a/daemon/acl.c
- +++ b/daemon/acl.c
- @@ -223,6 +223,18 @@ 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/getattr.c b/daemon/getattr.c
- index 7c5f241..97767fb 100644
- --- a/daemon/getattr.c
- +++ b/daemon/getattr.c
- @@ -60,7 +60,13 @@ static int parse_getattr(unsigned char *buffer, uint32_t length, nfs41_upcall *u
- {
- int status;
- getattr_upcall_args *args = &upcall->args.getattr;
- -
- +#if 1
- + EASSERT(length > 4);
- + if (length <= 4) {
- + status = ERROR_INVALID_PARAMETER;
- + goto out;
- + }
- +#endif
- status = safe_read(&buffer, &length, &args->query_class, sizeof(args->query_class));
- if (status) goto out;
- status = safe_read(&buffer, &length, &args->buf_len, sizeof(args->buf_len));
- @@ -80,6 +86,21 @@ static int handle_getattr(void *daemon_context, nfs41_upcall *upcall)
- nfs41_open_state *state = upcall->state_ref;
- nfs41_file_info info = { 0 };
- +#if 1
- + if (((char *)state->session) == ((char *)0xdddddddddddddddd)) {
- + eprintf("handle_getattr: Invalid session pointer 0xdddddddddddddddd\n");
- + status = ERROR_INVALID_PARAMETER;
- + goto out;
- + }
- +
- + EASSERT(state->file.fh.superblock != NULL);
- + if (state->file.fh.superblock == NULL) {
- + /* gisburn: fixme: maybe this should be |ERROR_INTERNAL_ERROR| ? */
- + status = ERROR_INVALID_PARAMETER;
- + goto out;
- + }
- +#endif
- +
- status = nfs41_cached_getattr(state->session, &state->file, &info);
- if (status) {
- eprintf("nfs41_cached_getattr() failed with %d\n", status);
- diff --git a/daemon/idmap.c b/daemon/idmap.c
- index 00af1fe..6947b6c 100644
- --- a/daemon/idmap.c
- +++ b/daemon/idmap.c
- @@ -133,7 +133,7 @@ static const struct config_option g_options[] = {
- OPT_ATTR("ldap_attr_gidNumber", "gidNumber", ATTR_GID),
- /* caching configuration */
- - OPT_INT("cache_ttl", "60", cache_ttl),
- + OPT_INT("cache_ttl", "6000", cache_ttl),
- };
- diff --git a/daemon/name_cache.c b/daemon/name_cache.c
- index 3f944fd..bf2b064 100644
- --- a/daemon/name_cache.c
- +++ b/daemon/name_cache.c
- @@ -351,12 +351,24 @@ static void copy_attrs(
- dst->type = src->type;
- dst->numlinks = src->numlinks;
- dst->mode = src->mode;
- - EASSERT(src->owner != NULL);
- + EASSERT(src->owner[0] != '\0');
- + if (src->owner[0] != '\0') {
- dst->owner = dst->owner_buf;
- (void)strcpy(dst->owner, src->owner);
- - EASSERT(src->owner_group != NULL);
- + }
- + else {
- + /* this should only happen for newly created files/dirs */
- + dst->owner = NULL;
- + }
- + EASSERT(src->owner_group[0] != '\0');
- + if (src->owner_group[0] != '\0') {
- dst->owner_group = dst->owner_group_buf;
- (void)strcpy(dst->owner_group, src->owner_group);
- + }
- + else {
- + /* this should only happen for newly created files/dirs */
- + dst->owner_group = NULL;
- + }
- dst->fileid = src->fileid;
- dst->hidden = src->hidden;
- dst->system = src->system;
- @@ -369,8 +381,11 @@ 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_OWNER | FATTR4_WORD1_OWNER_GROUP;
- + | FATTR4_WORD1_SYSTEM;
- + if (dst->owner)
- + dst->attrmask.arr[1] |= FATTR4_WORD1_OWNER;
- + if (dst->owner_group)
- + dst->attrmask.arr[1] |= FATTR4_WORD1_OWNER_GROUP;
- }
- diff --git a/daemon/nfs41_xdr.c b/daemon/nfs41_xdr.c
- index 9bde0f0..6889a79 100644
- --- a/daemon/nfs41_xdr.c
- +++ b/daemon/nfs41_xdr.c
- @@ -1815,6 +1815,7 @@ static bool_t decode_file_attrs(
- EASSERT(owner_len > 0);
- EASSERT(owner_len < sizeof(info->owner_group_buf));
- info->owner[owner_len] = '\0';
- + EASSERT(info->owner[0] != '\0');
- }
- if (attrs->attrmask.arr[1] & FATTR4_WORD1_OWNER_GROUP) {
- if (info->owner_group == NULL)
- @@ -1830,6 +1831,7 @@ static bool_t decode_file_attrs(
- EASSERT(owner_group_len > 0);
- EASSERT(owner_group_len < sizeof(info->owner_group_buf));
- info->owner_group[owner_group_len] = '\0';
- + EASSERT(info->owner_group[0] != '\0');
- }
- if (attrs->attrmask.arr[1] & FATTR4_WORD1_SPACE_AVAIL) {
- if (!xdr_u_hyper(xdr, &info->space_avail))
- diff --git a/daemon/open.c b/daemon/open.c
- index a9ffcb0..1f8bd54 100644
- --- a/daemon/open.c
- +++ b/daemon/open.c
- @@ -99,6 +99,24 @@ static void open_state_free(
- void nfs41_open_state_ref(
- IN nfs41_open_state *state)
- {
- +#if 1
- + /*
- + * gisburn: fixme: sometimes this happens under high parallel
- + * usage with multiple mounts - but why ?
- + * 0:038> kp
- + * Child-SP RetAddr Call Site
- + * 0000006d`431fde10 00007ff7`32f7d905 nfsd!nfs41_open_state_ref(struct __nfs41_open_state * state = 0x00000000`00000000)+0x31
- + * 0000006d`431fdf30 00007ff7`32f4d284 nfsd!upcall_parse(unsigned char * buffer = 0x0000006d`431fe180 "???", unsigned int length = 8, struct __nfs41_upcall * upcall = 0x0000006d`431ff1e0)+0x2e5
- + * 0000006d`431fe0b0 00007ffc`1ca24c7c nfsd!thread_main(void * args = 0x00007ff7`32fb6080)+0x144
- + * 0000006d`431ffe00 00007ffc`4d4b7344 ucrtbased!thread_start<unsigned int (void * parameter = 0x0000025d`a9c6def0)+0x9c
- + * 0000006d`431ffe60 00007ffc`4efc26b1 KERNEL32!BaseThreadInitThunk+0x14
- + * 0000006d`431ffe90 00000000`00000000 ntdll!RtlUserThreadStart+0x21
- + */
- + EASSERT(state != NULL);
- + if (state == NULL)
- + return;
- +#endif
- +
- const LONG count = InterlockedIncrement(&state->ref_count);
- dprintf(2, "nfs41_open_state_ref(%s) count %d\n", state->path.path, count);
- @@ -669,12 +687,47 @@ static int handle_open(void *daemon_context, nfs41_upcall *upcall)
- gid_t map_gid = -1;
- char *at_ch; /* pointer to '@' */
- +#if 1
- + /* this should only happen for newly created files/dirs */
- + if (((info.attrmask.arr[1] & FATTR4_WORD1_OWNER) == 0) ||
- + ((info.attrmask.arr[1] & FATTR4_WORD1_OWNER_GROUP) == 0)) {
- + bitmap4 og_attr_request = { 0 };
- + nfs41_file_info og_info = { 0 };
- + nfsacl41 acl = { 0 };
- +
- + og_attr_request.count = 2;
- + og_attr_request.arr[1] =
- + FATTR4_WORD1_OWNER | FATTR4_WORD1_OWNER_GROUP;
- + og_info.owner = og_info.owner_buf;
- + og_info.owner_group = og_info.owner_group_buf;
- + status = nfs41_getattr(state->session, &state->file,
- + &og_attr_request, &og_info);
- + if (status) {
- + eprintf("get_stat_data: nfs41_getattr('%s') "
- + "failed with %d\n",
- + state->path.path,
- + status);
- + goto out_free_state;
- + }
- +
- + info.owner = info.owner_buf;
- + (void)strcpy(info.owner, og_info.owner);
- + info.attrmask.arr[1] |= FATTR4_WORD1_OWNER;
- + info.owner_group = info.owner_group_buf;
- + (void)strcpy(info.owner_group, og_info.owner_group);
- + info.attrmask.arr[1] |= FATTR4_WORD1_OWNER_GROUP;
- + }
- +#endif
- +
- 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);
- + EASSERT(strlen(info.owner) > 0);
- + EASSERT(strlen(info.owner_group) > 0);
- +
- /* Make copies as we will modify them */
- (void)strcpy(owner, info.owner);
- (void)strcpy(owner_group, info.owner_group);
- @@ -698,8 +751,9 @@ static int handle_open(void *daemon_context, nfs41_upcall *upcall)
- }
- else {
- args->owner_local_uid = NFS_USER_NOBODY_UID;
- - eprintf("get_stat_data: "
- + eprintf("get_stat_data('%s'): "
- "no username mapping for '%s', fake uid=%d\n",
- + state->path.path,
- owner, args->owner_local_uid);
- }
- @@ -721,12 +775,14 @@ static int handle_open(void *daemon_context, nfs41_upcall *upcall)
- }
- else {
- args->owner_group_local_gid = NFS_GROUP_NOGROUP_GID;
- - eprintf("get_stat_data: "
- + eprintf("get_stat_data('%s'): "
- "no group mapping for '%s', fake gid=%d\n",
- + state->path.path,
- owner_group, args->owner_group_local_gid);
- }
- - dprintf(1, "handle_open: stat: owner=%u/'%s', owner_group=%u/'%s'\n",
- + dprintf(1, "handle_open('%s'): stat: owner=%u/'%s', owner_group=%u/'%s'\n",
- + state->path.path,
- (unsigned int)args->owner_local_uid, owner,
- (unsigned int)args->owner_group_local_gid, owner_group);
- #endif /* NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES */
- diff --git a/daemon/util.c b/daemon/util.c
- index 07aa2c6..c482624 100644
- --- a/daemon/util.c
- +++ b/daemon/util.c
- @@ -207,7 +207,9 @@ void nfs41_file_info_cpy(
- IN const nfs41_file_info *src)
- {
- (void)memcpy(dest, src, sizeof(nfs41_file_info));
- + if (src->owner != NULL)
- dest->owner = dest->owner_buf;
- + if (src->owner_group != NULL)
- dest->owner_group = dest->owner_group_buf;
- }
- diff --git a/libtirpc/src/clnt_vc.c b/libtirpc/src/clnt_vc.c
- index e0a9d30..bedbebe 100644
- --- a/libtirpc/src/clnt_vc.c
- +++ b/libtirpc/src/clnt_vc.c
- @@ -158,7 +158,7 @@ struct ct_data {
- * Yes, this is silly, and as soon as this code is proven to work, this
- * should be the first thing fixed. One step at a time.
- */
- -static int *vc_fd_locks;
- +static volatile int *vc_fd_locks;
- extern mutex_t clnt_fd_lock;
- static cond_t *vc_cv;
- #ifndef _WIN32
- @@ -211,17 +211,26 @@ static unsigned int WINAPI clnt_cb_thread(void *args)
- while(1) {
- cb_req header;
- void *res = NULL;
- +restart:
- mutex_lock(&clnt_fd_lock);
- while (vc_fd_locks[ct->ct_fd] ||
- !ct->use_stored_reply_msg ||
- (ct->use_stored_reply_msg && ct->reply_msg.rm_direction != CALL)) {
- if (cl->shutdown)
- break;
- - if (!cond_wait_timed(&vc_cv[ct->ct_fd], &clnt_fd_lock,
- - CALLBACK_TIMEOUT))
- - if (!vc_fd_locks[ct->ct_fd])
- + if (!cond_wait_timed(&vc_cv[ct->ct_fd], &clnt_fd_lock, CALLBACK_TIMEOUT)) {
- + if (!vc_fd_locks[ct->ct_fd]) {
- break;
- }
- + else
- + {
- + mutex_unlock(&clnt_fd_lock);
- + fprintf(stderr, "%04x: clnt_cb_thread: restart...\n", GetCurrentThreadId());
- + SwitchToThread(); /* sched_yield() */
- + goto restart;
- + }
- + }
- + }
- vc_fd_locks[ct->ct_fd] = GetCurrentThreadId();
- mutex_unlock(&clnt_fd_lock);
- @@ -923,8 +932,13 @@ clnt_vc_destroy(cl)
- GetCurrentThreadId(), cl->cb_thread);
- cl->shutdown = 1;
- mutex_unlock(&clnt_fd_lock);
- - cond_signal(&vc_cv[ct_fd]);
- - status = WaitForSingleObject(cl->cb_thread, INFINITE);
- +retry_signalandwaitforobject:
- + cond_signal(&vc_cv[ct_fd]); /* fixme: should broadcast everyone waiting... */
- + status = WaitForSingleObject(cl->cb_thread, 5000);
- + if (status == WAIT_TIMEOUT) {
- + fprintf(stderr, "%04x: clnt_vc_destroy: WaitForSingleObject timeout, retrying...\n", GetCurrentThreadId());
- + goto retry_signalandwaitforobject;
- + }
- fprintf(stdout, "%04x: terminated callback thread\n", GetCurrentThreadId());
- mutex_lock(&clnt_fd_lock);
- while (vc_fd_locks[ct_fd])
- 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_ */
msnfs41 experiments backup diff
Posted by Anonymous on Mon 30th Oct 2023 16:55
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.