pastebin - collaborative debugging tool
nrubsig.kpaste.net RSS

Difference between
modified post 8c3d3 by Anonymous on Thu 19th Oct 2023 18:05
original post 7d07a9 by Anonymous on Thu 19th Oct 2023 15:13
Download diff
Show old version | new version | both versions

    
11
diff --git a/daemon/acl.c b/daemon/acl.c
22
index 1d1eac4..9c30eeb 100644
33
--- a/daemon/acl.c
44
+++ b/daemon/acl.c
55
@@ -223,6 +223,19 @@ static int map_name_2_sid(nfs41_daemon_globals *nfs41dg, int query, DWORD *sid_l
66
             name = "roland_mainz";
77
             dprintf(ACLLVL, "map_name_2_sid: remap 1616 --> roland_mainz\n");
88
         }
99
+        else if (!strcmp(name, "swulsch")) {
1010
+            name = "siegfried_wulsch";
1111
+            dprintf(ACLLVL, "map_name_2_sid: remap swulsch --> siegfried_wulsch\n");
1212
+        }
1313
+        else if (!strcmp(name, "197609")) {
1414
+            name = "siegfried_wulsch";
1515
+            dprintf(ACLLVL, "map_name_2_sid: remap 197609 --> siegfried_wulsch\n");
1616
+        }
1717
+        else if (!strcmp(name, "1818")) {
1818
+            name = "siegfried_wulsch";
1919
+            dprintf(ACLLVL, "map_name_2_sid: remap 1818 --> siegfried_wulsch\n");
2020
+        }
2121
+
2222
     }
2323
 #endif /* NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID */
2424
25-
diff --git a/daemon/lookup.c b/daemon/lookup.c
25+
diff --git a/daemon/daemon_debug.h b/daemon/daemon_debug.h
26-
index ea0a9d2..a2862de 100644
26+
index f484d58..85b0507 100644
27-
--- a/daemon/lookup.c
27+
--- a/daemon/daemon_debug.h
28-
+++ b/daemon/lookup.c
28+
+++ b/daemon/daemon_debug.h
29-
@@ -85,7 +85,8 @@ static void init_component_args(
29+
@@ -34,6 +34,11 @@
30-
     args->attr_request.arr[1] = FATTR4_WORD1_MODE
30+
 #define DEFAULT_DEBUG_LEVEL 1
3631
37-
     args->getrootattr.attr_request = &args->attr_request;
32+
38-
     res->root.path = path;
33+
+#define DASSERT(exp) \
39-
diff --git a/daemon/name_cache.c b/daemon/name_cache.c
34+
+    if (!(exp)) { \
40-
index eaa0f36..3770214 100644
35+
+        dprintf(0, "ASSERTION '%s' in %s/%ld failed.\n", \
41-
--- a/daemon/name_cache.c
36+
+            __FILE__, (long)__LINE__, ""#exp""); }
42-
+++ b/daemon/name_cache.c
37+
+
43-
@@ -401,7 +401,11 @@ struct nfs41_name_cache {
38+
 /* daemon_debug.h */
44-
 static __inline bool_t name_cache_enabled(
39+
 void set_debug_level(int level);
45-
     IN struct nfs41_name_cache *cache)
40+
 void dprintf(int level, LPCSTR format, ...);
46-
 {
41+
diff --git a/daemon/lookup.c b/daemon/lookup.c
47-
+#if 1
42+
index ea0a9d2..a2862de 100644
48-
+    return 0; /* fixme: caching of owner/owner_group not supported yet */
43+
--- a/daemon/lookup.c
49-
+#else
44+
+++ b/daemon/lookup.c
50-
     return cache->expiration > 0;
45+
@@ -85,7 +85,8 @@ static void init_component_args(
51-
+#endif
46+
     args->attr_request.arr[1] = FATTR4_WORD1_MODE
52-
 }
47+
         | FATTR4_WORD1_NUMLINKS | FATTR4_WORD1_SYSTEM
48+
         | FATTR4_WORD1_TIME_ACCESS | FATTR4_WORD1_TIME_CREATE
5352
54-
 static __inline void name_cache_entry_rename(
53+
     args->getrootattr.attr_request = &args->attr_request;
55-
diff --git a/daemon/nfs41_types.h b/daemon/nfs41_types.h
54+
     res->root.path = path;
56-
index c5bad79..abdf2c2 100644
55+
diff --git a/daemon/name_cache.c b/daemon/name_cache.c
57-
--- a/daemon/nfs41_types.h
56+
index eaa0f36..3770214 100644
58-
+++ b/daemon/nfs41_types.h
57+
--- a/daemon/name_cache.c
59-
@@ -236,6 +236,10 @@ typedef struct __nfs41_file_info {
58+
+++ b/daemon/name_cache.c
60-
     char                    *owner;
59+
@@ -401,7 +401,11 @@ struct nfs41_name_cache {
61-
     char                    *owner_group;
60+
 static __inline bool_t name_cache_enabled(
62-
     uint32_t                aclsupport;
61+
     IN struct nfs41_name_cache *cache)
63-
+
62+
 {
64-
+    /* Buffers */
63+
+#if 1
65-
+    char owner_buf[NFS4_OPAQUE_LIMIT+1];
64+
+    return 0; /* fixme: caching of owner/owner_group not supported yet */
66-
+    char owner_group_buf[NFS4_OPAQUE_LIMIT+1];
65+
+#else
67-
 } nfs41_file_info;
66+
     return cache->expiration > 0;
67+
+#endif
6869
69-
 #endif /* !__NFS41_DAEMON_TYPES_H__ */
70+
 static __inline void name_cache_entry_rename(
70-
diff --git a/daemon/nfs41_xdr.c b/daemon/nfs41_xdr.c
71+
diff --git a/daemon/nfs41_types.h b/daemon/nfs41_types.h
71-
index 176b613..94f6d4a 100644
72+
index c5bad79..18a763a 100644
72-
--- a/daemon/nfs41_xdr.c
73+
--- a/daemon/nfs41_types.h
73-
+++ b/daemon/nfs41_xdr.c
74+
+++ b/daemon/nfs41_types.h
74-
@@ -1802,19 +1802,31 @@ static bool_t decode_file_attrs(
75+
@@ -236,6 +236,10 @@ typedef struct __nfs41_file_info {
75-
                 return FALSE;
76+
     char                    *owner;
76-
         }
77+
     char                    *owner_group;
77-
         if (attrs->attrmask.arr[1] & FATTR4_WORD1_OWNER) {
78+
     uint32_t                aclsupport;
8179
+
82-
+            char *ptr = info->owner;
80+
+    /* Buffers */
83-
             uint32_t owner_len;
81+
+    char owner_buf[NFS4_OPAQUE_LIMIT+1];
84-
             if (!xdr_bytes(xdr, &ptr, &owner_len,
82+
+    char owner_group_buf[NFS4_OPAQUE_LIMIT+1];
85-
-                            NFS4_OPAQUE_LIMIT))
83+
 } nfs41_file_info;
86-
+                            NFS4_OPAQUE_LIMIT)) {
84+
87-
+                info->owner = NULL;
85+
 #endif /* !__NFS41_DAEMON_TYPES_H__ */
86+
diff --git a/daemon/nfs41_xdr.c b/daemon/nfs41_xdr.c
8891
                 return FALSE;
9292
         }
93-
         if (attrs->attrmask.arr[1] & FATTR4_WORD1_OWNER_GROUP) {
93+
         if (attrs->attrmask.arr[1] & FATTR4_WORD1_OWNER) {
94-
-            char *ptr = &info->owner_group[0];
94+
-            char *ptr = &info->owner[0];
95-
+            if (info->owner_group == NULL)
95+
+            if (info->owner == NULL)
96-
+                info->owner_group = info->owner_group_buf;
96+
+                info->owner = info->owner_buf;
9797
+
98-
+            char *ptr = info->owner_group;
98+
+            char *ptr = info->owner;
99-
             uint32_t owner_group_len;
99+
             uint32_t owner_len;
100-
             if (!xdr_bytes(xdr, &ptr, &owner_group_len,
100+
             if (!xdr_bytes(xdr, &ptr, &owner_len,
101101
-                            NFS4_OPAQUE_LIMIT))
102102
+                            NFS4_OPAQUE_LIMIT)) {
103-
+                info->owner_group = NULL;
103+
+                info->owner = NULL;
104104
                 return FALSE;
105105
+            }
106-
+            /* fixme: add assert |owner_len < buffer size| */
106+
+            DASSERT(owner_len > 0);
107-
             info->owner_group[owner_group_len] = '\0';
107+
+            DASSERT(owner_len < sizeof(info->owner_group_buf));
108+
             info->owner[owner_len] = '\0';
108109
         }
109-
         if (attrs->attrmask.arr[1] & FATTR4_WORD1_SPACE_AVAIL) {
110+
         if (attrs->attrmask.arr[1] & FATTR4_WORD1_OWNER_GROUP) {
110-
diff --git a/daemon/open.c b/daemon/open.c
111+
-            char *ptr = &info->owner_group[0];
111-
index 13e82b2..1b60296 100644
112+
+            if (info->owner_group == NULL)
112-
--- a/daemon/open.c
113+
+                info->owner_group = info->owner_group_buf;
113-
+++ b/daemon/open.c
114+
+
114-
@@ -665,9 +665,11 @@ static int handle_open(void *daemon_context, nfs41_upcall *upcall)
115+
+            char *ptr = info->owner_group;
115-
 #ifdef NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES
116+
             uint32_t owner_group_len;
116-
         bitmap4 og_attr_request = { 0 };
117+
             if (!xdr_bytes(xdr, &ptr, &owner_group_len,
117-
         nfs41_file_info og_info = { 0 };
118+
-                            NFS4_OPAQUE_LIMIT))
118-
-        char owner[NFS4_OPAQUE_LIMIT], group[NFS4_OPAQUE_LIMIT];
119+
+                            NFS4_OPAQUE_LIMIT)) {
119-
         nfsacl41 acl = { 0 };
120+
+                info->owner_group = NULL;
120-
121+
                 return FALSE;
121-
+#if 1
122+
+            }
122-
+        (void)memcpy(&og_info, &info, sizeof(nfs41_file_info));
123+
+            DASSERT(owner_group_len > 0);
123-
+#else
124+
+            DASSERT(owner_group_len < sizeof(info->owner_group_buf));
124-
         /*
125+
             info->owner_group[owner_group_len] = '\0';
125-
          * gisburn:
126+
         }
126-
          * 1. We should cache owner/group information
127+
         if (attrs->attrmask.arr[1] & FATTR4_WORD1_SPACE_AVAIL) {
127-
@@ -677,14 +679,16 @@ static int handle_open(void *daemon_context, nfs41_upcall *upcall)
128+
diff --git a/daemon/open.c b/daemon/open.c
128-
          */
129+
index 13e82b2..d1220b3 100644
129-
         og_attr_request.count = 2;
130+
--- a/daemon/open.c
130-
         og_attr_request.arr[1] = FATTR4_WORD1_OWNER | FATTR4_WORD1_OWNER_GROUP;
131+
+++ b/daemon/open.c
131-
-        og_info.owner = owner;
132+
@@ -664,32 +664,19 @@ static int handle_open(void *daemon_context, nfs41_upcall *upcall)
132-
-        og_info.owner_group = group;
133+
133-
+        /* nfs41_getattr() will give us |og_info.owner_buf| on success */
134+
 #ifdef NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES
134-
+        og_info.owner = NULL;
135+
         bitmap4 og_attr_request = { 0 };
135-
+        /* nfs41_getattr() will give us |og_info.owner_group_buf| on success */
136+
-        nfs41_file_info og_info = { 0 };
136-
+        og_info.owner_group = NULL;
137+
-        char owner[NFS4_OPAQUE_LIMIT], group[NFS4_OPAQUE_LIMIT];
137-
         status = nfs41_getattr(state->session, &state->file, &og_attr_request, &og_info);
138+
+        char owner[NFS4_OPAQUE_LIMIT], owner_group[NFS4_OPAQUE_LIMIT];
138-
         if (status) {
139+
         nfsacl41 acl = { 0 };
139-
             eprintf("get_stat_data: nfs41_cached_getattr() failed with %d\n",
140+
140-
             status);
141+
-        /*
141-
         }
142+
-         * gisburn:
142-
-
143+
-         * 1. We should cache owner/group information
143-
+#endif
144+
-         * 2. We should always ask for
144-
         uid_t map_uid = -1;
145+
-         * FATTR4_WORD1_OWNER | FATTR4_WORD1_OWNER_GROUP with the other
145-
         gid_t gid_dummy = -1;
146+
-         * attributes
146-
         gid_t map_gid = -1;
147+
-         */
147-
diff --git a/sys/nfs41_build_features.h b/sys/nfs41_build_features.h
148+
-        og_attr_request.count = 2;
148-
index 93ee7a9..d43334a 100644
149+
-        og_attr_request.arr[1] = FATTR4_WORD1_OWNER | FATTR4_WORD1_OWNER_GROUP;
149-
--- a/sys/nfs41_build_features.h
150+
-        og_info.owner = owner;
150-
+++ b/sys/nfs41_build_features.h
151+
-        og_info.owner_group = group;
151-
@@ -32,19 +32,19 @@
152+
-        status = nfs41_getattr(state->session, &state->file, &og_attr_request, &og_info);
152-
 /*
153+
-        if (status) {
153-
  * NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES - return local uid/gid values
154+
-            eprintf("get_stat_data: nfs41_cached_getattr() failed with %d\n",
154-
  */
155+
-            status);
155-
-// #define NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES 1
156+
-        }
156-
+#define NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES 1
157+
-
158+
         uid_t map_uid = -1;
157162
163+
+        DASSERT(info.owner != NULL);
158168
 /*
159-
  * NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID - give NFS
169+
          * Map owner to local uid
160-
  * files which do not map to a local account a SID in the
170+
          *
161-
  * Unix_User+x/Unix_Group+x range
171+
@@ -697,12 +684,12 @@ static int handle_open(void *daemon_context, nfs41_upcall *upcall)
172+
          *  ("gisburn") or username@domain ("gisburn@sun.com")
162173
  */
163-
-// #define NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID 1
174+
         /* stomp over '@' */
164-
+#define NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID 1
175+
-        if (at_ch = strchr(og_info.owner, '@'))
176+
+        if (at_ch = strchr(owner, '@'))
165178
166-
 /*
179+
         if (nfs41_idmap_name_to_ids(
167-
  * NFS41_DRIVER_FEATURE_NAMESERVICE_CYGWIN - use Cygwin /usr/bin/getent
180+
             nfs41dg->idmapper,
168-
  * as "name service"
181+
-            og_info.owner,
169-
  */
182+
+            owner,
170-
-// #define NFS41_DRIVER_FEATURE_NAMESERVICE_CYGWIN 1
183+
             &map_uid,
171-
+#define NFS41_DRIVER_FEATURE_NAMESERVICE_CYGWIN 1
184+
             &gid_dummy) == 0) {
172-
185+
              args->owner_local_uid = map_uid;
173-
 #endif /* !_NFS41_DRIVER_BUILDFEATURES_ */
186+
@@ -711,7 +698,7 @@ static int handle_open(void *daemon_context, nfs41_upcall *upcall)
174-
187+
             args->owner_local_uid = NFS_USER_NOBODY_UID;
175-
188+
             eprintf("get_stat_data: "
176-
189+
                 "no username mapping for '%s', fake uid=%d\n",
177-
190+
-                og_info.owner, args->owner_local_uid);
178-
191+
+                owner, args->owner_local_uid);
179-
192+
         }
180193
181-
194+
         /*
182-
195+
@@ -721,12 +708,12 @@ static int handle_open(void *daemon_context, nfs41_upcall *upcall)
183-
196+
          * ("gisgrp") or username@domain ("gisgrp@sun.com")
184-
197+
          */
185-
198+
         /* stomp over '@' */
186-
199+
-        if (at_ch = strchr(og_info.owner_group, '@'))
187-
200+
+        if (at_ch = strchr(owner_group, '@'))
188-
201+
             *at_ch = '\0';
189202
190-
203+
         if (nfs41_idmap_group_to_gid(
191-
204+
             nfs41dg->idmapper,
192-
205+
-            og_info.owner_group,
193-
206+
+            owner_group,
194-
207+
             &map_gid) == 0) {
195-
208+
             args->owner_group_local_gid = map_gid;
196-
209+
         }
197-
210+
@@ -734,12 +721,12 @@ static int handle_open(void *daemon_context, nfs41_upcall *upcall)
198-
211+
             args->owner_group_local_gid = NFS_GROUP_NOGROUP_GID;
199-
212+
             eprintf("get_stat_data: "
200-
213+
                 "no group mapping for '%s', fake gid=%d\n",
201-
214+
-                og_info.owner_group, args->owner_group_local_gid);
202-
215+
+                owner_group, args->owner_group_local_gid);
203-
216+
         }
204217
205-
218+
         dprintf(1, "handle_open: stat: owner=%u/'%s', owner_group=%u/'%s'\n",
206-
219+
-            (unsigned int)args->owner_local_uid, og_info.owner,
207-
220+
-            (unsigned int)args->owner_group_local_gid, og_info.owner_group);
208-
221+
+            (unsigned int)args->owner_local_uid, owner,
209-
222+
+            (unsigned int)args->owner_group_local_gid, owner_group);
210-
223+
 #endif /* NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES */
211-
224+
     } else {
212-
225+
         nfs41_file_info createattrs = { 0 };
213-
226+
diff --git a/sys/nfs41_build_features.h b/sys/nfs41_build_features.h
214-
227+
index 93ee7a9..d43334a 100644
215-
228+
--- a/sys/nfs41_build_features.h
216-
229+
+++ b/sys/nfs41_build_features.h
217-
230+
@@ -32,19 +32,19 @@
218-
231+
 /*
219-
232+
  * NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES - return local uid/gid values
220-
233+
  */
221-
234+
-// #define NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES 1
222-
235+
+#define NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES 1
223236
224-
237+
 /*
225-
238+
  * NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID - give NFS
226-
239+
  * files which do not map to a local account a SID in the
227-
240+
  * Unix_User+x/Unix_Group+x range
228-
241+
  */
229-
242+
-// #define NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID 1
230-
243+
+#define NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID 1
231244
232-
245+
 /*
233-
246+
  * NFS41_DRIVER_FEATURE_NAMESERVICE_CYGWIN - use Cygwin /usr/bin/getent
234-
247+
  * as "name service"
235-
248+
  */
236-
249+
-// #define NFS41_DRIVER_FEATURE_NAMESERVICE_CYGWIN 1
237-
250+
+#define NFS41_DRIVER_FEATURE_NAMESERVICE_CYGWIN 1
238251
239-
252+
 #endif /* !_NFS41_DRIVER_BUILDFEATURES_ */
240253

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.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}




All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at