Difference between
modified post bf464d81 by Anonymous on Thu 7th Dec 2023 14:19
original post 6baeb7 by Anonymous on Thu 7th Dec 2023 14:18
Download diff
Show
old version |
new version |
both versions
| 1 | 1 | diff --git a/cygwin/Makefile b/cygwin/Makefile | |
| 2 | 2 | index b7a3b1e..41e2340 100644 | |
| 3 | 3 | --- a/cygwin/Makefile | |
| 4 | 4 | +++ b/cygwin/Makefile | |
| 5 | 5 | @@ -57,7 +57,11 @@ installdest: $(VS_BUILD_DIR)/nfsd.exe \ | |
| 6 | 6 | fi | |
| 7 | 7 | mkdir -p $(DESTDIR) | |
| 8 | 8 | mkdir -p $(DESTDIR)/cygdrive/c/cygwin64/sbin/ | |
| 9 | 9 | - mkdir -p $(DESTDIR)/cygdrive/c/cygwin64/usr/bin | |
| 10 | 10 | + # /usr/bin is a bind mount to C:/cygwin64/bin, so copy binaries to /cygdrive/c/cygwin64/bin | |
| 11 | 11 | + mkdir -p $(DESTDIR)/cygdrive/c/cygwin64/bin | |
| 12 | 12 | + # /usr/lib is a bind mount to C:/cygwin64/lib, so copy library data to /cygdrive/c/cygwin64/lib | |
| 13 | 13 | + mkdir -p $(DESTDIR)/cygdrive/c/cygwin64/lib | |
| 14 | 14 | + mkdir -p $(DESTDIR)/cygdrive/c/cygwin64/lib/msnfs41client | |
| 15 | 15 | cp -r $(VS_BUILD_DIR)/nfsd.exe $(DESTDIR)/cygdrive/c/cygwin64/sbin/nfsd_debug.exe | |
| 16 | 16 | cp -r $(VS_BUILD_DIR)/nfsd.pdb $(DESTDIR)/cygdrive/c/cygwin64/sbin/nfsd_debug.pdb | |
| 17 | 17 | cp -r $(VS_BUILD_DIR)/nfs_mount.* $(DESTDIR)/cygdrive/c/cygwin64/sbin/. | |
| 18 | - | @@ -68,17 +72,18 @@ installdest: $(VS_BUILD_DIR)/nfsd.exe \ | |
| 18 | + | @@ -70,15 +74,16 @@ installdest: $(VS_BUILD_DIR)/nfsd.exe \ | |
| 21 | 19 | cp $(PROJECT_BASEDIR_DIR)/etc_netconfig $(DESTDIR)/cygdrive/c/cygwin64/sbin/. | |
| 22 | - | - cp $(PROJECT_BASEDIR_DIR)/ms-nfs41-idmap.conf $(DESTDIR)/cygdrive/c/cygwin64/sbin/. | |
| 20 | + | cp $(PROJECT_BASEDIR_DIR)/ms-nfs41-idmap.conf $(DESTDIR)/cygdrive/c/cygwin64/sbin/. | |
| 23 | - | - cp $(CYGWIN_MAKEFILE_DIR)/devel/msnfs41client.bash $(DESTDIR)/cygdrive/c/cygwin64/sbin/. | |
| 21 | + | cp $(CYGWIN_MAKEFILE_DIR)/devel/msnfs41client.bash $(DESTDIR)/cygdrive/c/cygwin64/sbin/. | |
| 26 | 22 | + cp $(PROJECT_BASEDIR_DIR)/cygwin_idmapper.ksh $(DESTDIR)/cygdrive/c/cygwin64/lib/msnfs41client/. | |
| 27 | 23 | cp $(CYGWIN_MAKEFILE_DIR)/utils/mount_sshnfs/mount_sshnfs.ksh $(DESTDIR)/cygdrive/c/cygwin64/sbin/mount_sshnfs | |
| 28 | 24 | chmod a+x $(DESTDIR)/cygdrive/c/cygwin64/sbin/mount_sshnfs | |
| 29 | 25 | cp $(CYGWIN_MAKEFILE_DIR)/utils/sshnfs/sshnfs.ksh $(DESTDIR)/cygdrive/c/cygwin64/sbin/sshnfs | |
| 30 | 26 | chmod a+x $(DESTDIR)/cygdrive/c/cygwin64/sbin/sshnfs | |
| 31 | 27 | @ printf "# Package tests\n" | |
| 32 | 28 | - cp tests/winfsinfo1/winfsinfo.exe $(DESTDIR)/cygdrive/c/cygwin64/usr/bin/winfsinfo.exe | |
| 33 | 29 | + cp tests/winfsinfo1/winfsinfo.exe $(DESTDIR)/cygdrive/c/cygwin64/bin/winfsinfo.exe | |
| 34 | 30 | @ printf "# Package ksh93&co (if available) since Cygwin does not ship with it yet\n" | |
| 35 | 31 | - [[ -x /usr/bin/ksh93.exe ]] && cp /usr/bin/ksh93.exe $(DESTDIR)/cygdrive/c/cygwin64/usr/bin/ksh93.exe | |
| 36 | 32 | - [[ -x /usr/bin/shcomp.exe ]] && cp /usr/bin/shcomp.exe $(DESTDIR)/cygdrive/c/cygwin64/usr/bin/shcomp.exe | |
| 37 | 33 | + [[ -x /usr/bin/ksh93.exe ]] && cp /usr/bin/ksh93.exe $(DESTDIR)/cygdrive/c/cygwin64/bin/ksh93.exe | |
| 38 | 34 | + [[ -x /usr/bin/shcomp.exe ]] && cp /usr/bin/shcomp.exe $(DESTDIR)/cygdrive/c/cygwin64/bin/shcomp.exe | |
| 39 | 35 | @ printf "# Set file flags\n" | |
| 40 | 36 | (cd $(DESTDIR)/cygdrive/c/cygwin64/sbin/ ; chmod a+x *.exe *.dll *.sys *.bash) | |
| 41 | 37 | @printf "\n#\n# TEST sbin dir is %s\n#\n" "$(DESTDIR)/cygdrive/c/cygwin64/sbin/" | |
| 42 | 38 | @@ -86,6 +91,14 @@ installdest: $(VS_BUILD_DIR)/nfsd.exe \ | |
| 43 | 39 | @printf "\n#\n# Now use\n# $$ cd '%s' && bash ./msnfs41client.bash install #\n# to install the kernel driver as Admin\n#\n" \ | |
| 44 | 40 | "$(DESTDIR)/cygdrive/c/cygwin64/sbin/" | |
| 45 | 41 | ||
| 46 | 42 | +bintarball: installdest | |
| 47 | 43 | + (cd destdir && \ | |
| 48 | 44 | + tar -cvf - \ | |
| 49 | 45 | + --owner=SYSTEM \ | |
| 50 | 46 | + --group=SYSTEM \ | |
| 51 | 47 | + cygdrive/c/cygwin64 | \ | |
| 52 | 48 | + bzip2 -9 >msnfs41client_cygwin_binaries.tar.bz2) | |
| 53 | 49 | + | |
| 54 | 50 | # | |
| 55 | 51 | # clean destdir/, but only if nfsd*.exe does not use it right now | |
| 56 | 52 | # | |
| 57 | 53 | @@ -94,6 +107,6 @@ cleandest: | |
| 58 | 54 | printf 'DIR %q is in use by a process\n' "$DESTDIR" 1>&2 ; \ | |
| 59 | 55 | exit 1 ; \ | |
| 60 | 56 | fi | |
| 61 | 57 | - rm -r "$(DESTDIR)" | |
| 62 | 58 | + rm -rf "$(DESTDIR)" | |
| 63 | 59 | ||
| 64 | 60 | # EOF. | |
| 65 | 61 | diff --git a/daemon/getattr.c b/daemon/getattr.c | |
| 66 | 62 | index 7c5f241..7621dba 100644 | |
| 67 | 63 | --- a/daemon/getattr.c | |
| 68 | 64 | +++ b/daemon/getattr.c | |
| 69 | 65 | @@ -59,8 +59,19 @@ int nfs41_cached_getattr( | |
| 70 | 66 | static int parse_getattr(unsigned char *buffer, uint32_t length, nfs41_upcall *upcall) | |
| 71 | 67 | { | |
| 72 | 68 | int status; | |
| 73 | 69 | +#if 1 | |
| 74 | 70 | + EASSERT(length > 4); | |
| 75 | 71 | + if (length <= 4) { | |
| 76 | 72 | + status = ERROR_INVALID_PARAMETER; | |
| 77 | 73 | + goto out; | |
| 78 | 74 | + } | |
| 79 | 75 | + EASSERT(upcall->state_ref != NULL); | |
| 80 | 76 | + if (upcall->state_ref == NULL) { | |
| 81 | 77 | + status = ERROR_INVALID_PARAMETER; | |
| 82 | 78 | + goto out; | |
| 83 | 79 | + } | |
| 84 | 80 | +#endif | |
| 85 | 81 | getattr_upcall_args *args = &upcall->args.getattr; | |
| 86 | 82 | - | |
| 87 | 83 | status = safe_read(&buffer, &length, &args->query_class, sizeof(args->query_class)); | |
| 88 | 84 | if (status) goto out; | |
| 89 | 85 | status = safe_read(&buffer, &length, &args->buf_len, sizeof(args->buf_len)); | |
| 90 | 86 | @@ -80,6 +91,21 @@ static int handle_getattr(void *daemon_context, nfs41_upcall *upcall) | |
| 91 | 87 | nfs41_open_state *state = upcall->state_ref; | |
| 92 | 88 | nfs41_file_info info = { 0 }; | |
| 93 | 89 | ||
| 94 | 90 | +#if 1 | |
| 95 | 91 | + if (((char *)state->session) == ((char *)0xdddddddddddddddd)) { | |
| 96 | 92 | + eprintf("handle_getattr: Invalid session pointer 0xdddddddddddddddd\n"); | |
| 97 | 93 | + status = ERROR_INVALID_PARAMETER; | |
| 98 | 94 | + goto out; | |
| 99 | 95 | + } | |
| 100 | 96 | + | |
| 101 | 97 | + EASSERT(state->file.fh.superblock != NULL); | |
| 102 | 98 | + if (state->file.fh.superblock == NULL) { | |
| 103 | 99 | + /* gisburn: fixme: maybe this should be |ERROR_INTERNAL_ERROR| ? */ | |
| 104 | 100 | + status = ERROR_INVALID_PARAMETER; | |
| 105 | 101 | + goto out; | |
| 106 | 102 | + } | |
| 107 | 103 | +#endif | |
| 108 | 104 | + | |
| 109 | 105 | status = nfs41_cached_getattr(state->session, &state->file, &info); | |
| 110 | 106 | if (status) { | |
| 111 | 107 | eprintf("nfs41_cached_getattr() failed with %d\n", status); | |
| 112 | 108 | diff --git a/daemon/idmap_cygwin.c b/daemon/idmap_cygwin.c | |
| 113 | 109 | index 64c1bff..f8bb74e 100644 | |
| 114 | 110 | --- a/daemon/idmap_cygwin.c | |
| 115 | 111 | +++ b/daemon/idmap_cygwin.c | |
| 116 | 112 | @@ -40,7 +40,7 @@ | |
| 117 | 113 | ||
| 118 | 114 | #define CYGWIN_IDMAPPER_SCRIPT \ | |
| 119 | 115 | ("C:\\cygwin64\\bin\\ksh93.exe " \ | |
| 120 | 116 | - "/home/roland_mainz/work/msnfs41_uidmapping/ms-nfs41-client/cygwin_idmapper.ksh") | |
| 121 | 117 | + "/cygdrive/c/cygwin64/lib/msnfs41client/cygwin_idmapper.ksh") | |
| 122 | 118 | ||
| 123 | 119 | ||
| 124 | 120 | #ifdef NFS41_DRIVER_FEATURE_NAMESERVICE_CYGWIN | |
| 125 | 121 | diff --git a/daemon/nfs41_daemon.c b/daemon/nfs41_daemon.c | |
| 126 | 122 | index fe0683e..a43d51e 100644 | |
| 127 | 123 | --- a/daemon/nfs41_daemon.c | |
| 128 | 124 | +++ b/daemon/nfs41_daemon.c | |
| 129 | - | @@ -27,67 +27,67 @@ | |
| 125 | + | @@ -415,7 +415,21 @@ VOID ServiceStart(DWORD argc, LPTSTR *argv) | |
| 130 | - | #include <devioctl.h> | |
| 126 | + | #ifdef _DEBUG | |
| 131 | - | #include <lmcons.h> /* UNLEN for GetUserName() */ | |
| 127 | + | /* dump memory leaks to stderr on exit; this requires the debug heap, | |
| 132 | - | #include <iphlpapi.h> /* for GetNetworkParam() */ | |
| 128 | + | /* available only when built in debug mode under visual studio -cbodley */ | |
| 133 | - | -#include "nfs41_driver.h" /* for NFS41_USER_DEVICE_NAME_A */ | |
| 129 | + | - _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); | |
| 134 | - | -#include "nfs41_np.h" /* for NFS41NP_SHARED_MEMORY */ | |
| 130 | + | + | |
| 135 | - | - | |
| 131 | + | + int crtsetdbgflags = 0; | |
| 136 | - | -#include "nfs41_daemon.h" | |
| 132 | + | + crtsetdbgflags |= _CRTDBG_ALLOC_MEM_DF; /* use debug heap */ | |
| 137 | - | -#include "daemon_debug.h" | |
| 133 | + | + crtsetdbgflags |= _CRTDBG_LEAK_CHECK_DF; /* report leaks on exit */ | |
| 138 | - | -#include "upcall.h" | |
| 134 | + | +#if 1 | |
| 139 | - | -#include "sid.h" | |
| 135 | + | + /* | |
| 140 | - | -#include "util.h" | |
| 136 | + | + * _CRTDBG_DELAY_FREE_MEM_DF - Delay freeing of memory, but fill | |
| 141 | - | - | |
| 137 | + | + * memory blocks passed to |free()| with 0xdd. We rely on that to | |
| 142 | - | -/* nfs41_dg.num_worker_threads sets the actual number of worker threads */ | |
| 138 | + | + * see 0xdddddddddddddddd-pointers for use-after-free and catch | |
| 143 | - | -#define MAX_NUM_THREADS 1024 | |
| 139 | + | + * them in stress testing instead of having to deal with a core | |
| 144 | - | -#define DEFAULT_NUM_THREADS 32 | |
| 140 | + | + * dump | |
| 145 | - | -DWORD NFS41D_VERSION = 0; | |
| 141 | + | + */ | |
| 146 | - | - | |
| 142 | + | + crtsetdbgflags |= _CRTDBG_DELAY_FREE_MEM_DF; | |
| 147 | - | -static const char FILE_NETCONFIG[] = "C:\\etc\\netconfig"; | |
| 143 | + | +#endif | |
| 148 | - | - | |
| 144 | + | + (void)_CrtSetDbgFlag(crtsetdbgflags); | |
| 149 | - | -/* Globals */ | |
| 145 | + | _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE); | |
| 150 | - | -nfs41_daemon_globals nfs41_dg = { | |
| 146 | + | ||
| 151 | - | - .default_uid = NFS_USER_NOBODY_UID, | |
| 147 | + | /* | |
| 152 | - | - .default_gid = NFS_GROUP_NOGROUP_GID, | |
| 148 | + | diff --git a/daemon/nfs41_ops.c b/daemon/nfs41_ops.c | |
| 153 | - | - .num_worker_threads = DEFAULT_NUM_THREADS, | |
| 149 | + | index bcca070..f2a4f22 100644 | |
| 154 | - | -}; | |
| 150 | + | --- a/daemon/nfs41_ops.c | |
| 155 | - | - | |
| 151 | + | +++ b/daemon/nfs41_ops.c | |
| 156 | - | - | |
| 152 | + | @@ -400,6 +400,9 @@ int nfs41_open( | |
| 157 | - | -#ifndef STANDALONE_NFSD //make sure to define it in "sources" not here | |
| 153 | + | bool_t already_delegated = delegation->type == OPEN_DELEGATE_READ | |
| 158 | - | -#include "service.h" | |
| 154 | + | || delegation->type == OPEN_DELEGATE_WRITE; | |
| 159 | - | +#include "nfs41_driver.h" /* for NFS41_USER_DEVICE_NAME_A */ | |
| 155 | + | ||
| 160 | - | +#include "nfs41_np.h" /* for NFS41NP_SHARED_MEMORY */ | |
| 156 | + | + EASSERT(parent); | |
| 157 | + | + EASSERT(parent->fh.superblock); | |
| 161 | 158 | + | |
| 162 | - | +#include "nfs41_daemon.h" | |
| 159 | + | /* depending on the claim type, OPEN expects CURRENT_FH set | |
| 163 | - | +#include "daemon_debug.h" | |
| 160 | + | * to either the parent directory, or to the file itself */ | |
| 164 | - | +#include "upcall.h" | |
| 161 | + | switch (claim->claim) { | |
| 165 | - | +#include "sid.h" | |
| 162 | + | diff --git a/daemon/open.c b/daemon/open.c | |
| 166 | - | +#include "util.h" | |
| 163 | + | index 8c01ac1..1cbac2c 100644 | |
| 167 | - | + | |
| 164 | + | --- a/daemon/open.c | |
| 168 | - | +/* nfs41_dg.num_worker_threads sets the actual number of worker threads */ | |
| 165 | + | +++ b/daemon/open.c | |
| 169 | - | +#define MAX_NUM_THREADS 1024 | |
| 166 | + | @@ -99,6 +99,24 @@ static void open_state_free( | |
| 170 | - | +#define DEFAULT_NUM_THREADS 32 | |
| 167 | + | void nfs41_open_state_ref( | |
| 171 | - | +DWORD NFS41D_VERSION = 0; | |
| 168 | + | IN nfs41_open_state *state) | |
| 172 | - | + | |
| 169 | + | { | |
| 173 | - | +static const char FILE_NETCONFIG[] = "C:\\etc\\netconfig"; | |
| 170 | + | +#if 1 | |
| 174 | - | + | |
| 171 | + | + /* | |
| 175 | - | +/* Globals */ | |
| 172 | + | + * gisburn: fixme: sometimes this happens under high parallel | |
| 176 | - | +nfs41_daemon_globals nfs41_dg = { | |
| 173 | + | + * usage with multiple mounts - but why ? | |
| 177 | - | + .default_uid = NFS_USER_NOBODY_UID, | |
| 174 | + | + * 0:038> kp | |
| 178 | - | + .default_gid = NFS_GROUP_NOGROUP_GID, | |
| 175 | + | + * Child-SP RetAddr Call Site | |
| 179 | - | + .num_worker_threads = DEFAULT_NUM_THREADS, | |
| 176 | + | + * 0000006d`431fde10 00007ff7`32f7d905 nfsd!nfs41_open_state_ref(struct __nfs41_open_state * state = 0x00000000`00000000)+0x31 | |
| 180 | - | +}; | |
| 177 | + | + * 0000006d`431fdf30 00007ff7`32f4d284 nfsd!upcall_parse(unsigned char * buffer = 0x0000006d`431fe180 "???", unsigned int length = 8, struct __nfs41_upcall * upcall = 0x0000006d`431ff1e0)+0x2e5 | |
| 178 | + | + * 0000006d`431fe0b0 00007ffc`1ca24c7c nfsd!thread_main(void * args = 0x00007ff7`32fb6080)+0x144 | |
| 181 | 187 | + | |
| 182 | - | + | |
| 188 | + | const LONG count = InterlockedIncrement(&state->ref_count); | |
| 183 | - | +#ifndef STANDALONE_NFSD //make sure to define it in "sources" not here | |
| 189 | + | ||
| 184 | - | +#include "service.h" | |
| 190 | + | dprintf(2, "nfs41_open_state_ref(%s) count %d\n", state->path.path, count); | |
| 185 | - | HANDLE stop_event = NULL; | |
| 191 | + | diff --git a/daemon/upcall.c b/daemon/upcall.c | |
| 186 | - | #endif | |
| 192 | + | index bd13c61..7778429 100644 | |
| 187 | - | typedef struct _nfs41_process_thread { | |
| 193 | + | --- a/daemon/upcall.c | |
| 188 | - | HANDLE handle; | |
| 194 | + | +++ b/daemon/upcall.c | |
| 189 | - | - uint32_t tid; | |
| 195 | + | @@ -121,6 +121,7 @@ int upcall_parse( | |
| 190 | - | -} nfs41_process_thread; | |
| 196 | + | /* parse the operation's arguments */ | |
| 191 | - | - | |
| 197 | + | op = g_upcall_op_table[upcall->opcode]; | |
| 192 | - | -static int map_current_user_to_ids(nfs41_idmapper *idmapper, uid_t *uid, gid_t *gid) | |
| 198 | + | if (op && op->parse) { | |
| 193 | - | -{ | |
| 199 | + | + EASSERT(length > 0); | |
| 194 | - | - char username[UNLEN + 1]; | |
| 200 | + | status = op->parse(buffer, length, upcall); | |
| 195 | - | - DWORD len = UNLEN + 1; | |
| 201 | + | if (status) { | |
| 196 | - | + uint32_t tid; | |
| 202 | + | eprintf("parsing of upcall '%s' failed with %d.\n", | |
| 197 | - | +} nfs41_process_thread; | |
| 203 | + | diff --git a/sys/nfs41_build_features.h b/sys/nfs41_build_features.h | |
| 198 | - | + | |
| 204 | + | index 93ee7a9..d43334a 100644 | |
| 199 | - | +static int map_current_user_to_ids(nfs41_idmapper *idmapper, uid_t *uid, gid_t *gid) | |
| 205 | + | --- a/sys/nfs41_build_features.h | |
| 200 | - | +{ | |
| 206 | + | +++ b/sys/nfs41_build_features.h | |
| 201 | - | + char username[UNLEN + 1]; | |
| 207 | + | @@ -32,19 +32,19 @@ | |
| 202 | - | + DWORD len = UNLEN + 1; | |
| 208 | + | /* | |
| 203 | - | int status = NO_ERROR; | |
| 209 | + | * NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES - return local uid/gid values | |
| 204 | - | - | |
| 210 | + | */ | |
| 205 | - | - if (!GetUserNameA(username, &len)) { | |
| 211 | + | -// #define NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES 1 | |
| 206 | - | - status = GetLastError(); | |
| 212 | + | +#define NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES 1 | |
| 207 | - | - eprintf("map_current_user_to_ids: GetUserName() failed with %d\n", status); | |
| 213 | + | ||
| 208 | - | - goto out; | |
| 214 | + | /* | |
| 209 | - | - } | |
| 215 | + | * NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID - give NFS | |
| 210 | - | - dprintf(1, "map_current_user_to_ids: mapping user %s\n", username); | |
| 216 | + | * files which do not map to a local account a SID in the | |
| 211 | - | - | |
| 217 | + | * Unix_User+x/Unix_Group+x range | |
| 212 | - | - if (nfs41_idmap_name_to_ids(idmapper, username, uid, gid)) { | |
| 218 | + | */ | |
| 213 | - | - /* instead of failing for auth_sys, fall back to 'nobody' uid/gid */ | |
| 219 | + | -// #define NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID 1 | |
| 214 | - | - *uid = nfs41_dg.default_uid; | |
| 220 | + | +#define NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID 1 | |
| 215 | - | - *gid = nfs41_dg.default_gid; | |
| 221 | + | ||
| 216 | - | - } | |
| 222 | + | /* | |
| 217 | - | -out: | |
| 223 | + | * NFS41_DRIVER_FEATURE_NAMESERVICE_CYGWIN - use Cygwin /usr/bin/getent | |
| 218 | - | - return status; | |
| 224 | + | * as "name service" | |
| 219 | - | + | |
| 225 | + | */ | |
| 220 | - | + if (!GetUserNameA(username, &len)) { | |
| 226 | + | -// #define NFS41_DRIVER_FEATURE_NAMESERVICE_CYGWIN 1 | |
| 221 | - | + status = GetLastError(); | |
| 227 | + | +#define NFS41_DRIVER_FEATURE_NAMESERVICE_CYGWIN 1 | |
| 222 | - | + eprintf("map_current_user_to_ids: GetUserName() failed with %d\n", status); | |
| 228 | + | ||
| 223 | - | + goto out; | |
| 229 | + | #endif /* !_NFS41_DRIVER_BUILDFEATURES_ */ | |
| 224 | - | + } | |
| 230 | + | diff --git a/tests/winlocktest1/winlocktest1.ksh b/tests/winlocktest1/winlocktest1.ksh | |
| 225 | - | + dprintf(1, "map_current_user_to_ids: mapping user %s\n", username); | |
| 231 | + | old mode 100644 | |
| 226 | - | + | |
| 232 | + | new mode 100755 | |
| 227 | - | + if (nfs41_idmap_name_to_ids(idmapper, username, uid, gid)) { | |
| 233 | + | ||
| 228 | - | + /* instead of failing for auth_sys, fall back to 'nobody' uid/gid */ | |
| 234 | + | ||
| 229 | - | + *uid = nfs41_dg.default_uid; | |
| 235 | + | ||
| 230 | - | + *gid = nfs41_dg.default_gid; | |
| 236 | + | ||
| 231 | - | + } | |
| 237 | + | ||
| 232 | - | +out: | |
| 238 | + | ||
| 233 | - | + return status; | |
| 239 | + | ||
| 234 | - | } | |
| 240 | + | ||
| 235 | - | - | |
| 241 | + | ||
| 236 | - | -static unsigned int WINAPI thread_main(void *args) | |
| 242 | + | ||
| 237 | - | -{ | |
| 243 | + | ||
| 238 | - | - nfs41_daemon_globals *nfs41dg = (nfs41_daemon_globals *)args; | |
| 244 | + | ||
| 239 | - | - DWORD status = 0; | |
| 245 | + | ||
| 240 | - | - HANDLE pipe; | |
| 246 | + | ||
| 241 | - | - // buffer used to process upcall, assumed to be fixed size. | |
| 247 | + | ||
| 242 | - | + | |
| 248 | + | ||
| 243 | - | +static unsigned int WINAPI thread_main(void *args) | |
| 249 | + | ||
| 244 | - | +{ | |
| 250 | + | ||
| 245 | - | + nfs41_daemon_globals *nfs41dg = (nfs41_daemon_globals *)args; | |
| 251 | + | ||
| 246 | - | + DWORD status = 0; | |
| 252 | + | ||
| 247 | - | + HANDLE pipe; | |
| 253 | + | ||
| 248 | - | + // buffer used to process upcall, assumed to be fixed size. | |
| 254 | + | ||
| 249 | - | // if we ever need to handle non-cached IO, need to make it dynamic | |
| 255 | + | ||
| 250 | - | unsigned char outbuf[UPCALL_BUF_SIZE], inbuf[UPCALL_BUF_SIZE]; | |
| 256 | + | ||
| 251 | - | DWORD inbuf_len = UPCALL_BUF_SIZE, outbuf_len; | |
| 257 | + | ||
| 252 | - | @@ -113,29 +113,29 @@ static unsigned int WINAPI thread_main(void *args) | |
| 258 | + | ||
| 253 | - | status = upcall_parse(outbuf, (uint32_t)outbuf_len, &upcall); | |
| 259 | + | ||
| 254 | - | if (status) { | |
| 260 | + | ||
| 255 | - | upcall.status = status; | |
| 261 | + | ||
| 256 | - | - goto write_downcall; | |
| 262 | + | ||
| 257 | - | - } | |
| 263 | + | ||
| 258 | - | - | |
| 264 | + | ||
| 259 | - | - /* | |
| 265 | + | ||
| 260 | - | - * Map current username to uid/gid | |
| 266 | + | ||
| 261 | - | - * Each thread can handle a different user | |
| 267 | + | ||
| 262 | - | - */ | |
| 268 | + | ||
| 263 | - | - status = map_current_user_to_ids(nfs41dg->idmapper, | |
| 269 | + | ||
| 264 | - | - &upcall.uid, &upcall.gid); | |
| 270 | + | ||
| 265 | - | - if (status) { | |
| 271 | + | ||
| 266 | - | - upcall.status = status; | |
| 272 | + | ||
| 267 | - | - goto write_downcall; | |
| 273 | + | ||
| 268 | - | + goto write_downcall; | |
| 274 | + | ||
| 269 | - | + } | |
| 275 | + | ||
| 270 | - | + | |
| 276 | + | ||
| 271 | - | + /* | |
| 277 | + | ||
| 272 | - | + * Map current username to uid/gid | |
| 278 | + | ||
| 273 | - | + * Each thread can handle a different user | |
| 279 | + | ||
| 274 | - | + */ | |
| 280 | + | ||
| 275 | - | + status = map_current_user_to_ids(nfs41dg->idmapper, | |
| 281 | + | ||
| 276 | - | + &upcall.uid, &upcall.gid); | |
| 282 | + | ||
| 277 | - | + if (status) { | |
| 283 | + | ||
| 278 | - | + upcall.status = status; | |
| 284 | + | ||
| 279 | - | + goto write_downcall; | |
| 285 | + | ||
| 280 | - | } | |
| 286 | + | ||
| 281 | 287 | ||
| 282 | - | if (upcall.opcode == NFS41_SHUTDOWN) { | |
| 288 | + | ||
| 283 | - | printf("Shutting down..\n"); | |
| 289 | + | ||
| 284 | - | - exit(0); | |
| 290 | + | ||
| 285 | - | - } | |
| 291 | + | ||
| 286 | - | - | |
| 292 | + | ||
| 287 | - | - status = upcall_handle(&nfs41_dg, &upcall); | |
| 293 | + | ||
| 288 | - | - | |
| 294 | + | ||
| 289 | - | -write_downcall: | |
| 295 | + | ||
| 290 | - | - dprintf(1, "writing downcall: xid=%lld opcode=%s status=%d " | |
| 296 | + | ||
| 291 | - | + exit(0); | |
| 297 | + | ||
| 292 | - | + } | |
| 298 | + | ||
| 293 | - | + | |
| 299 | + | ||
| 294 | - | + status = upcall_handle(&nfs41_dg, &upcall); | |
| 300 | + | ||
| 295 | - | + | |
| 301 | + | ||
| 296 | - | +write_downcall: | |
| 302 | + | ||
| 297 | - | + dprintf(1, "writing downcall: xid=%lld opcode=%s status=%d " | |
| 303 | + | ||
| 298 | - | "get_last_error=%d\n", upcall.xid, opcode2string(upcall.opcode), | |
| 304 | + | ||
| 299 | - | upcall.status, upcall.last_error); | |
| 305 | + | ||
| 300 | 306 | ||
| 301 | - | @@ -182,18 +182,18 @@ static bool_t check_for_files() | |
| 307 | + | ||
| 302 | - | fclose(fd); | |
| 308 | + | ||
| 303 | - | return TRUE; | |
| 309 | + | ||
| 304 | - | } | |
| 310 | + | ||
| 305 | - | - | |
| 311 | + | ||
| 306 | - | -static void PrintUsage() | |
| 312 | + | ||
| 307 | - | -{ | |
| 313 | + | ||
| 308 | - | - (void)fprintf(stderr, "Usage: nfsd.exe -d <debug_level> " | |
| 314 | + | ||
| 309 | - | - "--noldap " | |
| 315 | + | ||
| 310 | - | - "--uid <non-zero value> " | |
| 316 | + | ||
| 311 | - | - "--gid <non-zero value> " | |
| 317 | + | ||
| 312 | - | - "--numworkerthreads <value-between 16 and %d> " | |
| 318 | + | ||
| 313 | - | - "\n", MAX_NUM_THREADS); | |
| 319 | + | ||
| 314 | - | -} | |
| 320 | + | ||
| 315 | - | -static bool_t parse_cmdlineargs(int argc, TCHAR *argv[], nfsd_args *out) | |
| 321 | + | ||
| 316 | - | -{ | |
| 322 | + | ||
| 317 | - | + | |
| 323 | + | ||
| 318 | - | +static void PrintUsage() | |
| 324 | + | ||
| 319 | - | +{ | |
| 325 | + | ||
| 320 | - | + (void)fprintf(stderr, "Usage: nfsd.exe -d <debug_level> " | |
| 326 | + | ||
| 321 | - | + "--noldap " | |
| 327 | + | ||
| 322 | - | + "--uid <non-zero value> " | |
| 328 | + | ||
| 323 | - | + "--gid <non-zero value> " | |
| 329 | + | ||
| 324 | - | + "--numworkerthreads <value-between 16 and %d> " | |
| 330 | + | ||
| 325 | - | + "\n", MAX_NUM_THREADS); | |
| 331 | + | ||
| 326 | - | +} | |
| 332 | + | ||
| 327 | - | +static bool_t parse_cmdlineargs(int argc, TCHAR *argv[], nfsd_args *out) | |
| 333 | + | ||
| 328 | - | +{ | |
| 334 | + | ||
| 329 | - | int i; | |
| 335 | + | ||
| 330 | 336 | ||
| 331 | - | /* set defaults. */ | |
| 337 | + | ||
| 332 | - | @@ -223,60 +223,60 @@ static bool_t parse_cmdlineargs(int argc, TCHAR *argv[], nfsd_args *out) | |
| 338 | + | ||
| 333 | - | ++i; | |
| 339 | + | ||
| 334 | - | if (i >= argc) { | |
| 340 | + | ||
| 335 | - | fprintf(stderr, "Missing uid value\n"); | |
| 341 | + | ||
| 336 | - | - PrintUsage(); | |
| 342 | + | ||
| 337 | - | - return FALSE; | |
| 343 | + | ||
| 338 | - | - } | |
| 344 | + | ||
| 339 | - | - nfs41_dg.default_uid = _ttoi(argv[i]); | |
| 345 | + | ||
| 340 | - | - if (!nfs41_dg.default_uid) { | |
| 346 | + | ||
| 341 | - | - fprintf(stderr, "Invalid (or missing) anonymous uid value of %d\n", | |
| 347 | + | ||
| 342 | - | - nfs41_dg.default_uid); | |
| 348 | + | ||
| 343 | - | - return FALSE; | |
| 349 | + | ||
| 344 | - | - } | |
| 350 | + | ||
| 345 | - | - } | |
| 351 | + | ||
| 346 | - | + PrintUsage(); | |
| 352 | + | ||
| 347 | - | + return FALSE; | |
| 353 | + | ||
| 348 | - | + } | |
| 354 | + | ||
| 349 | - | + nfs41_dg.default_uid = _ttoi(argv[i]); | |
| 355 | + | ||
| 350 | - | + if (!nfs41_dg.default_uid) { | |
| 356 | + | ||
| 351 | - | + fprintf(stderr, "Invalid (or missing) anonymous uid value of %d\n", | |
| 357 | + | ||
| 352 | - | + nfs41_dg.default_uid); | |
| 358 | + | ||
| 353 | - | + return FALSE; | |
| 359 | + | ||
| 354 | - | + } | |
| 360 | + | ||
| 355 | - | + } | |
| 361 | + | ||
| 356 | - | else if (_tcscmp(argv[i], TEXT("--gid")) == 0) { /* no LDAP, setting default gid */ | |
| 362 | + | ||
| 357 | - | ++i; | |
| 363 | + | ||
| 358 | - | if (i >= argc) { | |
| 364 | + | ||
| 359 | - | fprintf(stderr, "Missing gid value\n"); | |
| 365 | + | ||
| 360 | - | - PrintUsage(); | |
| 366 | + | ||
| 361 | - | - return FALSE; | |
| 367 | + | ||
| 362 | - | - } | |
| 368 | + | ||
| 363 | - | - nfs41_dg.default_gid = _ttoi(argv[i]); | |
| 369 | + | ||
| 364 | - | - } | |
| 370 | + | ||
| 365 | - | - else if (_tcscmp(argv[i], TEXT("--numworkerthreads")) == 0) { | |
| 371 | + | ||
| 366 | - | - ++i; | |
| 372 | + | ||
| 367 | - | - if (i >= argc) { | |
| 373 | + | ||
| 368 | - | - fprintf(stderr, "Missing value for num_worker_threads\n"); | |
| 374 | + | ||
| 369 | - | - PrintUsage(); | |
| 375 | + | ||
| 370 | - | - return FALSE; | |
| 376 | + | ||
| 371 | - | - } | |
| 377 | + | ||
| 372 | - | - nfs41_dg.num_worker_threads = _ttoi(argv[i]); | |
| 378 | + | ||
| 373 | - | - if (nfs41_dg.num_worker_threads < 16) { | |
| 379 | + | ||
| 374 | - | - fprintf(stderr, "--numworkerthreads requires at least 16 worker threads\n"); | |
| 380 | + | ||
| 375 | - | - PrintUsage(); | |
| 381 | + | ||
| 376 | - | - return FALSE; | |
| 382 | + | ||
| 377 | - | - } | |
| 383 | + | ||
| 378 | - | - if (nfs41_dg.num_worker_threads >= MAX_NUM_THREADS) { | |
| 384 | + | ||
| 379 | - | - fprintf(stderr, | |
| 385 | + | ||
| 380 | - | - "--numworkerthreads supports a maximum of " | |
| 386 | + | ||
| 381 | - | - "%d worker threads\n", | |
| 387 | + | ||
| 382 | - | - MAX_NUM_THREADS); | |
| 388 | + | ||
| 383 | - | - PrintUsage(); | |
| 389 | + | ||
| 384 | - | - return FALSE; | |
| 390 | + | ||
| 385 | - | - } | |
| 391 | + | ||
| 386 | - | - } | |
| 392 | + | ||
| 387 | - | - else | |
| 393 | + | ||
| 388 | - | - fprintf(stderr, "Unrecognized option '%s', disregarding.\n", argv[i]); | |
| 394 | + | ||
| 389 | - | - } | |
| 395 | + | ||
| 390 | - | - } | |
| 396 | + | ||
| 391 | - | - | |
| 397 | + | ||
| 392 | - | - (void)fprintf(stdout, "parse_cmdlineargs: debug_level %d ldap is %d " | |
| 398 | + | ||
| 393 | - | -#ifdef NFS41_DRIVER_FEATURE_NAMESERVICE_CYGWIN | |
| 399 | + | ||
| 394 | - | - "idmap_cygwin is 1 " | |
| 400 | + | ||
| 395 | - | -#endif /* NFS41_DRIVER_FEATURE_NAMESERVICE_CYGWIN */ | |
| 401 | + | ||
| 396 | - | - "\n", | |
| 402 | + | ||
| 397 | - | - out->debug_level, out->ldap_enable); | |
| 403 | + | ||
| 398 | - | - return TRUE; | |
| 404 | + | ||
| 399 | - | -} | |
| 405 | + | ||
| 400 | - | + PrintUsage(); | |
| 406 | + | ||
| 401 | - | + return FALSE; | |
| 407 | + | ||
| 402 | - | + } | |
| 408 | + | ||
| 403 | - | + nfs41_dg.default_gid = _ttoi(argv[i]); | |
| 409 | + | ||
| 404 | - | + } | |
| 410 | + | ||
| 405 | - | + else if (_tcscmp(argv[i], TEXT("--numworkerthreads")) == 0) { | |
| 411 | + | ||
| 406 | - | + ++i; | |
| 412 | + | ||
| 407 | - | + if (i >= argc) { | |
| 413 | + | ||
| 408 | - | + fprintf(stderr, "Missing value for num_worker_threads\n"); | |
| 414 | + | ||
| 409 | - | + PrintUsage(); | |
| 415 | + | ||
| 410 | - | + return FALSE; | |
| 416 | + | ||
| 411 | - | + } | |
| 417 | + | ||
| 412 | - | + nfs41_dg.num_worker_threads = _ttoi(argv[i]); | |
| 418 | + | ||
| 413 | - | + if (nfs41_dg.num_worker_threads < 16) { | |
| 419 | + | ||
| 414 | - | + fprintf(stderr, "--numworkerthreads requires at least 16 worker threads\n"); | |
| 420 | + | ||
| 415 | - | + PrintUsage(); | |
| 421 | + | ||
| 416 | - | + return FALSE; | |
| 422 | + | ||
| 417 | - | + } | |
| 423 | + | ||
| 418 | - | + if (nfs41_dg.num_worker_threads >= MAX_NUM_THREADS) { | |
| 424 | + | ||
| 419 | - | + fprintf(stderr, | |
| 425 | + | ||
| 420 | - | + "--numworkerthreads supports a maximum of " | |
| 426 | + | ||
| 421 | - | + "%d worker threads\n", | |
| 427 | + | ||
| 422 | - | + MAX_NUM_THREADS); | |
| 428 | + | ||
| 423 | - | + PrintUsage(); | |
| 429 | + | ||
| 424 | - | + return FALSE; | |
| 430 | + | ||
| 425 | - | + } | |
| 431 | + | ||
| 426 | - | + } | |
| 432 | + | ||
| 427 | - | + else | |
| 433 | + | ||
| 428 | - | + fprintf(stderr, "Unrecognized option '%s', disregarding.\n", argv[i]); | |
| 434 | + | ||
| 429 | - | + } | |
| 435 | + | ||
| 430 | - | + } | |
| 436 | + | ||
| 431 | - | + | |
| 437 | + | ||
| 432 | - | + (void)fprintf(stdout, "parse_cmdlineargs: debug_level %d ldap is %d " | |
| 438 | + | ||
| 433 | - | +#ifdef NFS41_DRIVER_FEATURE_NAMESERVICE_CYGWIN | |
| 439 | + | ||
| 434 | - | + "idmap_cygwin is 1 " | |
| 440 | + | ||
| 435 | - | +#endif /* NFS41_DRIVER_FEATURE_NAMESERVICE_CYGWIN */ | |
| 441 | + | ||
| 436 | - | + "\n", | |
| 442 | + | ||
| 437 | - | + out->debug_level, out->ldap_enable); | |
| 443 | + | ||
| 438 | - | + return TRUE; | |
| 444 | + | ||
| 439 | - | +} | |
| 445 | + | ||
| 440 | 446 | ||
| 441 | - | static void print_getaddrinfo(struct addrinfo *ptr) | |
| 447 | + | ||
| 442 | - | { | |
| 448 | + | ||
| 443 | - | @@ -358,15 +358,15 @@ static int getdomainname() | |
| 449 | + | ||
| 444 | - | for (i = 0; i < len; i++) | |
| 450 | + | ||
| 445 | - | if (p[i] == '.') | |
| 451 | + | ||
| 446 | - | break; | |
| 452 | + | ||
| 447 | - | - if (i == len) | |
| 453 | + | ||
| 448 | - | - break; | |
| 454 | + | ||
| 449 | - | - flag = TRUE; | |
| 455 | + | ||
| 450 | - | - memcpy(nfs41_dg.localdomain_name, &hostname[i+1], len-i); | |
| 456 | + | ||
| 451 | - | - dprintf(1, "getdomainname: domainname %s %d\n", | |
| 457 | + | ||
| 452 | - | - nfs41_dg.localdomain_name, strlen(nfs41_dg.localdomain_name)); | |
| 458 | + | ||
| 453 | - | - goto out_loop; | |
| 459 | + | ||
| 454 | - | - } | |
| 460 | + | ||
| 455 | - | - break; | |
| 461 | + | ||
| 456 | - | + if (i == len) | |
| 462 | + | ||
| 457 | - | + break; | |
| 463 | + | ||
| 458 | - | + flag = TRUE; | |
| 464 | + | ||
| 459 | - | + memcpy(nfs41_dg.localdomain_name, &hostname[i+1], len-i); | |
| 465 | + | ||
| 460 | - | + dprintf(1, "getdomainname: domainname %s %d\n", | |
| 466 | + | ||
| 461 | - | + nfs41_dg.localdomain_name, strlen(nfs41_dg.localdomain_name)); | |
| 467 | + | ||
| 462 | - | + goto out_loop; | |
| 468 | + | ||
| 463 | - | + } | |
| 469 | + | ||
| 464 | - | + break; | |
| 470 | + | ||
| 465 | - | default: | |
| 471 | + | ||
| 466 | - | break; | |
| 472 | + | ||
| 467 | - | } | |
| 473 | + | ||
| 468 | - | @@ -378,15 +378,15 @@ out_loop: | |
| 474 | + | ||
| 469 | - | "Set this machine's domain name:\n" | |
| 475 | + | ||
| 470 | - | "System > ComputerName > Change > More > mydomain\n"); | |
| 476 | + | ||
| 471 | - | } | |
| 477 | + | ||
| 472 | - | - freeaddrinfo(result); | |
| 478 | + | ||
| 473 | - | - } else { | |
| 479 | + | ||
| 474 | - | - dprintf(1, "domain name is %s\n", net_info->DomainName); | |
| 480 | + | ||
| 475 | - | - memcpy(nfs41_dg.localdomain_name, net_info->DomainName, | |
| 481 | + | ||
| 476 | - | - strlen(net_info->DomainName)); | |
| 482 | + | ||
| 477 | - | - nfs41_dg.localdomain_name[strlen(net_info->DomainName)] = '\0'; | |
| 483 | + | ||
| 478 | - | - } | |
| 484 | + | ||
| 479 | - | -out_free: | |
| 485 | + | ||
| 480 | - | - free(net_info); | |
| 486 | + | ||
| 481 | - | + freeaddrinfo(result); | |
| 487 | + | ||
| 482 | - | + } else { | |
| 488 | + | ||
| 483 | - | + dprintf(1, "domain name is %s\n", net_info->DomainName); | |
| 489 | + | ||
| 484 | - | + memcpy(nfs41_dg.localdomain_name, net_info->DomainName, | |
| 490 | + | ||
| 485 | - | + strlen(net_info->DomainName)); | |
| 491 | + | ||
| 486 | - | + nfs41_dg.localdomain_name[strlen(net_info->DomainName)] = '\0'; | |
| 492 | + | ||
| 487 | - | + } | |
| 493 | + | ||
| 488 | - | +out_free: | |
| 494 | + | ||
| 489 | - | + free(net_info); | |
| 495 | + | ||
| 490 | - | out: | |
| 496 | + | ||
| 491 | - | return status; | |
| 497 | + | ||
| 492 | - | } | |
| 498 | + | ||
| 493 | - | @@ -398,24 +398,38 @@ VOID ServiceStart(DWORD argc, LPTSTR *argv) | |
| 499 | + | ||
| 494 | - | #endif | |
| 500 | + | ||
| 495 | - | { | |
| 501 | + | ||
| 496 | - | DWORD status = 0, len; | |
| 502 | + | ||
| 497 | - | - // handle to our drivers | |
| 503 | + | ||
| 498 | - | - HANDLE pipe; | |
| 504 | + | ||
| 499 | - | - nfs41_process_thread tids[MAX_NUM_THREADS]; | |
| 505 | + | ||
| 500 | - | - int i; | |
| 506 | + | ||
| 501 | - | - nfsd_args cmd_args; | |
| 507 | + | ||
| 502 | - | - | |
| 508 | + | ||
| 503 | - | - if (!check_for_files()) | |
| 509 | + | ||
| 504 | - | - exit(1); | |
| 510 | + | ||
| 505 | - | - if (!parse_cmdlineargs(argc, argv, &cmd_args)) | |
| 511 | + | ||
| 506 | - | - exit(1); | |
| 512 | + | ||
| 507 | - | - set_debug_level(cmd_args.debug_level); | |
| 513 | + | ||
| 508 | - | - open_log_files(); | |
| 514 | + | ||
| 509 | - | - sidcache_init(); | |
| 515 | + | ||
| 510 | - | - | |
| 516 | + | ||
| 511 | - | -#ifdef _DEBUG | |
| 517 | + | ||
| 512 | - | - /* dump memory leaks to stderr on exit; this requires the debug heap, | |
| 518 | + | ||
| 513 | - | + // handle to our drivers | |
| 519 | + | ||
| 514 | - | + HANDLE pipe; | |
| 520 | + | ||
| 515 | - | + nfs41_process_thread tids[MAX_NUM_THREADS]; | |
| 521 | + | ||
| 516 | - | + int i; | |
| 522 | + | ||
| 517 | - | + nfsd_args cmd_args; | |
| 523 | + | ||
| 518 | - | + | |
| 524 | + | ||
| 519 | - | + if (!check_for_files()) | |
| 525 | + | ||
| 520 | - | + exit(1); | |
| 526 | + | ||
| 521 | - | + if (!parse_cmdlineargs(argc, argv, &cmd_args)) | |
| 527 | + | ||
| 522 | - | + exit(1); | |
| 528 | + | ||
| 523 | - | + set_debug_level(cmd_args.debug_level); | |
| 529 | + | ||
| 524 | - | + open_log_files(); | |
| 530 | + | ||
| 525 | - | + sidcache_init(); | |
| 531 | + | ||
| 526 | - | + | |
| 532 | + | ||
| 527 | - | +#ifdef _DEBUG | |
| 533 | + | ||
| 528 | - | + /* dump memory leaks to stderr on exit; this requires the debug heap, | |
| 534 | + | ||
| 529 | - | /* available only when built in debug mode under visual studio -cbodley */ | |
| 535 | + | ||
| 530 | - | - _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); | |
| 536 | + | ||
| 531 | - | + | |
| 537 | + | ||
| 532 | - | + int crtsetdbgflags = 0; | |
| 538 | + | ||
| 533 | - | + crtsetdbgflags |= _CRTDBG_ALLOC_MEM_DF; /* use debug heap */ | |
| 539 | + | ||
| 534 | - | + crtsetdbgflags |= _CRTDBG_LEAK_CHECK_DF; /* report leaks on exit */ | |
| 540 | + | ||
| 535 | - | +#if 1 | |
| 541 | + | ||
| 536 | - | + /* | |
| 542 | + | ||
| 537 | - | + * _CRTDBG_DELAY_FREE_MEM_DF - Delay freeing of memory, but fill | |
| 543 | + | ||
| 538 | - | + * memory blocks passed to |free()| with 0xdd. We rely on that to | |
| 544 | + | ||
| 539 | - | + * see 0xdddddddddddddddd-pointers for use-after-free and catch | |
| 545 | + | ||
| 540 | - | + * them in stress testing instead of having to deal with a core | |
| 546 | + | ||
| 541 | - | + * dump | |
| 547 | + | ||
| 542 | - | + */ | |
| 548 | + | ||
| 543 | - | + crtsetdbgflags |= _CRTDBG_DELAY_FREE_MEM_DF; | |
| 549 | + | ||
| 544 | - | +#endif | |
| 550 | + | ||
| 545 | - | + (void)_CrtSetDbgFlag(crtsetdbgflags); | |
| 551 | + | ||
| 546 | - | _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE); | |
| 552 | + | ||
| 547 | 553 | ||
| 548 | - | /* | |
| 554 | + | ||
| 549 | - | @@ -434,34 +448,34 @@ VOID ServiceStart(DWORD argc, LPTSTR *argv) | |
| 555 | + | ||
| 550 | - | * needed for acls */ | |
| 556 | + | ||
| 551 | - | if (getdomainname()) { | |
| 557 | + | ||
| 552 | - | eprintf("Could not get domain name\n"); | |
| 558 | + | ||
| 553 | - | - exit(1); | |
| 559 | + | ||
| 554 | - | - } | |
| 560 | + | ||
| 555 | - | - | |
| 561 | + | ||
| 556 | - | - /* | |
| 562 | + | ||
| 557 | - | - * Set high priority class to avoid that the daemon gets stomped | |
| 563 | + | ||
| 558 | - | - * by other processes, which might lead to some kind of priority | |
| 564 | + | ||
| 559 | - | - * inversion | |
| 565 | + | ||
| 560 | - | - */ | |
| 566 | + | ||
| 561 | - | - if(SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS)) { | |
| 567 | + | ||
| 562 | - | - dprintf(0, "Running as HIGH_PRIORITY_CLASS\n"); | |
| 568 | + | ||
| 563 | - | - } | |
| 569 | + | ||
| 564 | - | - else { | |
| 570 | + | ||
| 565 | - | - eprintf("Failed to enter HIGH_PRIORITY_CLASS mode\n"); | |
| 571 | + | ||
| 566 | - | - } | |
| 572 | + | ||
| 567 | - | - | |
| 573 | + | ||
| 568 | - | -#ifdef NFS41_DRIVER_FEATURE_NAMESERVICE_CYGWIN | |
| 574 | + | ||
| 569 | - | - /* force enable for cygwin getent passwd/group testing */ | |
| 575 | + | ||
| 570 | - | - cmd_args.ldap_enable = TRUE; | |
| 576 | + | ||
| 571 | - | - DASSERT(0/* test asserts*/, 0); | |
| 577 | + | ||
| 572 | - | -#endif /* NFS41_DRIVER_FEATURE_NAMESERVICE_CYGWIN */ | |
| 578 | + | ||
| 573 | - | - | |
| 579 | + | ||
| 574 | - | - nfs41_server_list_init(); | |
| 580 | + | ||
| 575 | - | - | |
| 581 | + | ||
| 576 | - | - if (cmd_args.ldap_enable) { | |
| 582 | + | ||
| 577 | - | - status = nfs41_idmap_create(&(nfs41_dg.idmapper)); | |
| 583 | + | ||
| 578 | - | - if (status) { | |
| 584 | + | ||
| 579 | - | - eprintf("id mapping initialization failed with %d\n", status); | |
| 585 | + | ||
| 580 | - | - goto out_logs; | |
| 586 | + | ||
| 581 | - | + exit(1); | |
| 587 | + | ||
| 582 | - | + } | |
| 588 | + | ||
| 583 | - | + | |
| 589 | + | ||
| 584 | - | + /* | |
| 590 | + | ||
| 585 | - | + * Set high priority class to avoid that the daemon gets stomped | |
| 591 | + | ||
| 586 | - | + * by other processes, which might lead to some kind of priority | |
| 592 | + | ||
| 587 | - | + * inversion | |
| 593 | + | ||
| 588 | - | + */ | |
| 594 | + | ||
| 589 | - | + if(SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS)) { | |
| 595 | + | ||
| 590 | - | + dprintf(0, "Running as HIGH_PRIORITY_CLASS\n"); | |
| 596 | + | ||
| 591 | - | + } | |
| 597 | + | ||
| 592 | - | + else { | |
| 598 | + | ||
| 593 | - | + eprintf("Failed to enter HIGH_PRIORITY_CLASS mode\n"); | |
| 599 | + | ||
| 594 | - | + } | |
| 600 | + | ||
| 595 | - | + | |
| 601 | + | ||
| 596 | - | +#ifdef NFS41_DRIVER_FEATURE_NAMESERVICE_CYGWIN | |
| 602 | + | ||
| 597 | - | + /* force enable for cygwin getent passwd/group testing */ | |
| 603 | + | ||
| 598 | - | + cmd_args.ldap_enable = TRUE; | |
| 604 | + | ||
| 599 | - | + DASSERT(0/* test asserts*/, 0); | |
| 605 | + | ||
| 600 | - | +#endif /* NFS41_DRIVER_FEATURE_NAMESERVICE_CYGWIN */ | |
| 606 | + | ||
| 601 | - | + | |
| 607 | + | ||
| 602 | - | + nfs41_server_list_init(); | |
| 608 | + | ||
| 603 | - | + | |
| 609 | + | ||
| 604 | - | + if (cmd_args.ldap_enable) { | |
| 610 | + | ||
| 605 | - | + status = nfs41_idmap_create(&(nfs41_dg.idmapper)); | |
| 611 | + | ||
| 606 | - | + if (status) { | |
| 612 | + | ||
| 607 | - | + eprintf("id mapping initialization failed with %d\n", status); | |
| 613 | + | ||
| 608 | - | + goto out_logs; | |
| 614 | + | ||
| 609 | - | } | |
| 615 | + | ||
| 610 | - | } | |
| 616 | + | ||
| 611 | 617 | ||
| 612 | - | @@ -489,17 +503,17 @@ VOID ServiceStart(DWORD argc, LPTSTR *argv) | |
| 618 | + | ||
| 613 | - | #ifndef STANDALONE_NFSD | |
| 619 | + | ||
| 614 | - | stop_event = CreateEvent(NULL, TRUE, FALSE, NULL); | |
| 620 | + | ||
| 615 | - | if (stop_event == NULL) | |
| 621 | + | ||
| 616 | - | - goto out_pipe; | |
| 622 | + | ||
| 617 | - | -#endif | |
| 623 | + | ||
| 618 | - | - | |
| 624 | + | ||
| 619 | - | - dprintf(1, "Starting %d worker threads...\n", | |
| 625 | + | ||
| 620 | - | - (int)nfs41_dg.num_worker_threads); | |
| 626 | + | ||
| 621 | - | - for (i = 0; i < nfs41_dg.num_worker_threads; i++) { | |
| 627 | + | ||
| 622 | - | - tids[i].handle = (HANDLE)_beginthreadex(NULL, 0, thread_main, | |
| 628 | + | ||
| 623 | - | - &nfs41_dg, 0, &tids[i].tid); | |
| 629 | + | ||
| 624 | - | - if (tids[i].handle == INVALID_HANDLE_VALUE) { | |
| 630 | + | ||
| 625 | - | - status = GetLastError(); | |
| 631 | + | ||
| 626 | - | - eprintf("_beginthreadex failed %d\n", status); | |
| 632 | + | ||
| 627 | - | + goto out_pipe; | |
| 633 | + | ||
| 628 | - | +#endif | |
| 634 | + | ||
| 629 | - | + | |
| 635 | + | ||
| 630 | - | + dprintf(1, "Starting %d worker threads...\n", | |
| 636 | + | ||
| 631 | - | + (int)nfs41_dg.num_worker_threads); | |
| 637 | + | ||
| 632 | - | + for (i = 0; i < nfs41_dg.num_worker_threads; i++) { | |
| 638 | + | ||
| 633 | - | + tids[i].handle = (HANDLE)_beginthreadex(NULL, 0, thread_main, | |
| 639 | + | ||
| 634 | - | + &nfs41_dg, 0, &tids[i].tid); | |
| 640 | + | ||
| 635 | - | + if (tids[i].handle == INVALID_HANDLE_VALUE) { | |
| 641 | + | ||
| 636 | - | + status = GetLastError(); | |
| 642 | + | ||
| 637 | - | + eprintf("_beginthreadex failed %d\n", status); | |
| 643 | + | ||
| 638 | - | goto out_pipe; | |
| 644 | + | ||
| 639 | - | } | |
| 645 | + | ||
| 640 | - | } | |
| 646 | + | ||
| 641 | - | @@ -508,22 +522,22 @@ VOID ServiceStart(DWORD argc, LPTSTR *argv) | |
| 647 | + | ||
| 642 | - | if (!ReportStatusToSCMgr(SERVICE_RUNNING, NO_ERROR, 0)) | |
| 648 | + | ||
| 643 | - | goto out_pipe; | |
| 649 | + | ||
| 644 | - | WaitForSingleObject(stop_event, INFINITE); | |
| 650 | + | ||
| 645 | - | -#else | |
| 651 | + | ||
| 646 | - | - //This can be changed to waiting on an array of handles and using waitformultipleobjects | |
| 652 | + | ||
| 647 | - | - dprintf(1, "Parent waiting for children threads\n"); | |
| 653 | + | ||
| 648 | - | - for (i = 0; i < nfs41_dg.num_worker_threads; i++) | |
| 654 | + | ||
| 649 | - | - WaitForSingleObject(tids[i].handle, INFINITE ); | |
| 655 | + | ||
| 650 | - | -#endif | |
| 656 | + | ||
| 651 | - | - dprintf(1, "Parent woke up!!!!\n"); | |
| 657 | + | ||
| 652 | - | - | |
| 658 | + | ||
| 653 | - | -out_pipe: | |
| 659 | + | ||
| 654 | - | - CloseHandle(pipe); | |
| 660 | + | ||
| 655 | - | -out_idmap: | |
| 661 | + | ||
| 656 | - | - if (nfs41_dg.idmapper) | |
| 662 | + | ||
| 657 | - | - nfs41_idmap_free(nfs41_dg.idmapper); | |
| 663 | + | ||
| 658 | - | -out_logs: | |
| 664 | + | ||
| 659 | - | -#ifndef STANDALONE_NFSD | |
| 665 | + | ||
| 660 | - | - close_log_files(); | |
| 666 | + | ||
| 661 | - | +#else | |
| 667 | + | ||
| 662 | - | + //This can be changed to waiting on an array of handles and using waitformultipleobjects | |
| 668 | + | ||
| 663 | - | + dprintf(1, "Parent waiting for children threads\n"); | |
| 669 | + | ||
| 664 | - | + for (i = 0; i < nfs41_dg.num_worker_threads; i++) | |
| 670 | + | ||
| 665 | - | + WaitForSingleObject(tids[i].handle, INFINITE ); | |
| 671 | + | ||
| 666 | - | +#endif | |
| 672 | + | ||
| 667 | - | + dprintf(1, "Parent woke up!!!!\n"); | |
| 673 | + | ||
| 668 | - | + | |
| 674 | + | ||
| 669 | - | +out_pipe: | |
| 675 | + | ||
| 670 | - | + CloseHandle(pipe); | |
| 676 | + | ||
| 671 | - | +out_idmap: | |
| 677 | + | ||
| 672 | - | + if (nfs41_dg.idmapper) | |
| 678 | + | ||
| 673 | - | + nfs41_idmap_free(nfs41_dg.idmapper); | |
| 679 | + | ||
| 674 | - | +out_logs: | |
| 680 | + | ||
| 675 | - | +#ifndef STANDALONE_NFSD | |
| 681 | + | ||
| 676 | - | + close_log_files(); | |
| 682 | + | ||
| 677 | - | #endif | |
| 683 | + | ||
| 678 | - | return; | |
| 684 | + | ||
| 679 | - | } | |
| 685 | + | ||
| 680 | - | diff --git a/daemon/nfs41_ops.c b/daemon/nfs41_ops.c | |
| 686 | + | ||
| 681 | - | index bcca070..f2a4f22 100644 | |
| 687 | + | ||
| 682 | - | --- a/daemon/nfs41_ops.c | |
| 688 | + | ||
| 683 | - | +++ b/daemon/nfs41_ops.c | |
| 689 | + | ||
| 684 | - | @@ -400,6 +400,9 @@ int nfs41_open( | |
| 690 | + | ||
| 685 | - | bool_t already_delegated = delegation->type == OPEN_DELEGATE_READ | |
| 691 | + | ||
| 686 | - | || delegation->type == OPEN_DELEGATE_WRITE; | |
| 692 | + | ||
| 687 | 693 | ||
| 688 | - | + EASSERT(parent); | |
| 694 | + | ||
| 689 | - | + EASSERT(parent->fh.superblock); | |
| 695 | + | ||
| 690 | - | + | |
| 696 | + | ||
| 691 | - | /* depending on the claim type, OPEN expects CURRENT_FH set | |
| 697 | + | ||
| 692 | - | * to either the parent directory, or to the file itself */ | |
| 698 | + | ||
| 693 | - | switch (claim->claim) { | |
| 699 | + | ||
| 694 | - | diff --git a/daemon/open.c b/daemon/open.c | |
| 700 | + | ||
| 695 | - | index 8c01ac1..1cbac2c 100644 | |
| 701 | + | ||
| 696 | - | --- a/daemon/open.c | |
| 702 | + | ||
| 697 | - | +++ b/daemon/open.c | |
| 703 | + | ||
| 698 | - | @@ -99,6 +99,24 @@ static void open_state_free( | |
| 704 | + | ||
| 699 | - | void nfs41_open_state_ref( | |
| 705 | + | ||
| 700 | - | IN nfs41_open_state *state) | |
| 706 | + | ||
| 701 | - | { | |
| 707 | + | ||
| 702 | - | +#if 1 | |
| 708 | + | ||
| 703 | - | + /* | |
| 709 | + | ||
| 704 | - | + * gisburn: fixme: sometimes this happens under high parallel | |
| 710 | + | ||
| 705 | - | + * usage with multiple mounts - but why ? | |
| 711 | + | ||
| 706 | - | + * 0:038> kp | |
| 712 | + | ||
| 707 | - | + * Child-SP RetAddr Call Site | |
| 713 | + | ||
| 708 | - | + * 0000006d`431fde10 00007ff7`32f7d905 nfsd!nfs41_open_state_ref(struct __nfs41_open_state * state = 0x00000000`00000000)+0x31 | |
| 714 | + | ||
| 709 | - | + * 0000006d`431fdf30 00007ff7`32f4d284 nfsd!upcall_parse(unsigned char * buffer = 0x0000006d`431fe180 "???", unsigned int length = 8, struct __nfs41_upcall * upcall = 0x0000006d`431ff1e0)+0x2e5 | |
| 715 | + | ||
| 710 | - | + * 0000006d`431fe0b0 00007ffc`1ca24c7c nfsd!thread_main(void * args = 0x00007ff7`32fb6080)+0x144 | |
| 716 | + | ||
| 711 | - | + * 0000006d`431ffe00 00007ffc`4d4b7344 ucrtbased!thread_start<unsigned int (void * parameter = 0x0000025d`a9c6def0)+0x9c | |
| 717 | + | ||
| 712 | - | + * 0000006d`431ffe60 00007ffc`4efc26b1 KERNEL32!BaseThreadInitThunk+0x14 | |
| 718 | + | ||
| 713 | - | + * 0000006d`431ffe90 00000000`00000000 ntdll!RtlUserThreadStart+0x21 | |
| 719 | + | ||
| 714 | - | + */ | |
| 720 | + | ||
| 715 | - | + EASSERT(state != NULL); | |
| 721 | + | ||
| 716 | - | + if (state == NULL) | |
| 722 | + | ||
| 717 | - | + return; | |
| 723 | + | ||
| 718 | - | +#endif | |
| 724 | + | ||
| 719 | - | + | |
| 725 | + | ||
| 720 | - | const LONG count = InterlockedIncrement(&state->ref_count); | |
| 726 | + | ||
| 721 | 727 | ||
| 722 | - | dprintf(2, "nfs41_open_state_ref(%s) count %d\n", state->path.path, count); | |
| 728 | + | ||
| 723 | - | diff --git a/daemon/upcall.c b/daemon/upcall.c | |
| 729 | + | ||
| 724 | - | index bd13c61..7778429 100644 | |
| 730 | + | ||
| 725 | - | --- a/daemon/upcall.c | |
| 731 | + | ||
| 726 | - | +++ b/daemon/upcall.c | |
| 732 | + | ||
| 727 | - | @@ -121,6 +121,7 @@ int upcall_parse( | |
| 733 | + | ||
| 728 | - | /* parse the operation's arguments */ | |
| 734 | + | ||
| 729 | - | op = g_upcall_op_table[upcall->opcode]; | |
| 735 | + | ||
| 730 | - | if (op && op->parse) { | |
| 736 | + | ||
| 731 | - | + EASSERT(length > 0); | |
| 737 | + | ||
| 732 | - | status = op->parse(buffer, length, upcall); | |
| 738 | + | ||
| 733 | - | if (status) { | |
| 739 | + | ||
| 734 | - | eprintf("parsing of upcall '%s' failed with %d.\n", | |
| 740 | + | ||
| 735 | - | diff --git a/sys/nfs41_build_features.h b/sys/nfs41_build_features.h | |
| 741 | + | ||
| 736 | - | index 93ee7a9..d43334a 100644 | |
| 742 | + | ||
| 737 | - | --- a/sys/nfs41_build_features.h | |
| 743 | + | ||
| 738 | - | +++ b/sys/nfs41_build_features.h | |
| 744 | + | ||
| 739 | - | @@ -32,19 +32,19 @@ | |
| 745 | + | ||
| 740 | - | /* | |
| 746 | + | ||
| 741 | - | * NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES - return local uid/gid values | |
| 747 | + | ||
| 742 | - | */ | |
| 748 | + | ||
| 743 | - | -// #define NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES 1 | |
| 749 | + | ||
| 744 | - | +#define NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES 1 | |
| 750 | + | ||
| 745 | 751 | ||
| 746 | - | /* | |
| 752 | + | ||
| 747 | - | * NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID - give NFS | |
| 753 | + | ||
| 748 | - | * files which do not map to a local account a SID in the | |
| 754 | + | ||
| 749 | - | * Unix_User+x/Unix_Group+x range | |
| 755 | + | ||
| 750 | - | */ | |
| 756 | + | ||
| 751 | - | -// #define NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID 1 | |
| 757 | + | ||
| 752 | - | +#define NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID 1 | |
| 758 | + | ||
| 753 | 759 | ||
| 754 | - | /* | |
| 760 | + | ||
| 755 | - | * NFS41_DRIVER_FEATURE_NAMESERVICE_CYGWIN - use Cygwin /usr/bin/getent | |
| 761 | + | ||
| 756 | - | * as "name service" | |
| 762 | + | ||
| 757 | - | */ | |
| 763 | + | ||
| 758 | - | -// #define NFS41_DRIVER_FEATURE_NAMESERVICE_CYGWIN 1 | |
| 764 | + | ||
| 759 | - | +#define NFS41_DRIVER_FEATURE_NAMESERVICE_CYGWIN 1 | |
| 765 | + | ||
| 760 | 766 | ||
| 761 | - | #endif /* !_NFS41_DRIVER_BUILDFEATURES_ */ | |
| 767 | + | ||
| 762 | - | diff --git a/tests/winlocktest1/winlocktest1.ksh b/tests/winlocktest1/winlocktest1.ksh | |
| 768 | + | ||
| 763 | - | old mode 100644 | |
| 769 | + | ||
| 764 | - | new mode 100755 | |
| 770 | + | ||
| 765 | 771 |
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.
nrubsig.kpaste.net RSS