pastebin - collaborative debugging tool
nrubsig.kpaste.net RSS

Difference between
modified post e01 by Anonymous on Thu 19th Oct 2023 20:51
original post f551bf by Anonymous on Thu 19th Oct 2023 19:26
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
2525
diff --git a/daemon/daemon_debug.h b/daemon/daemon_debug.h
2626
index f484d58..b77e7d7 100644
2727
--- a/daemon/daemon_debug.h
2828
+++ b/daemon/daemon_debug.h
2929
@@ -34,6 +34,11 @@
3030
 #define DEFAULT_DEBUG_LEVEL 1
3131
3232
3333
+#define DASSERT(exp) \
3434
+    if (!(exp)) { \
3535
+        eprintf("ASSERTION '%s' in '%s'/%ld failed.\n", \
3636
+            ""#exp"", __FILE__, (long)__LINE__); }
3737
+
3838
 /* daemon_debug.h */
3939
 void set_debug_level(int level);
4040
 void dprintf(int level, LPCSTR format, ...);
4141
diff --git a/daemon/lookup.c b/daemon/lookup.c
4242
index ea0a9d2..f72afe5 100644
4343
--- a/daemon/lookup.c
4444
+++ b/daemon/lookup.c
4545
@@ -85,7 +85,8 @@ static void init_component_args(
4646
     args->attr_request.arr[1] = FATTR4_WORD1_MODE
4747
         | FATTR4_WORD1_NUMLINKS | FATTR4_WORD1_SYSTEM
4848
         | FATTR4_WORD1_TIME_ACCESS | FATTR4_WORD1_TIME_CREATE
4949
-        | FATTR4_WORD1_TIME_MODIFY;
5050
+        | FATTR4_WORD1_TIME_MODIFY
5151
+        | FATTR4_WORD1_OWNER | FATTR4_WORD1_OWNER_GROUP;
5252
5353
     args->getrootattr.attr_request = &args->attr_request;
5454
     res->root.path = path;
5555
@@ -210,8 +211,12 @@ static int server_lookup(
5656
     if (count == 0) {
5757
         if (target_out)
5858
             *target_out = dir;
5959
-        if (info_out)
6060
+        if (info_out) {
6161
+            /* fixme: need |copy_nfs41_file_info()| */
6262
             memcpy(info_out, res->getrootattr.info, sizeof(nfs41_file_info));
6363
+            info_out->owner = info_out->owner_buf;
6464
+            info_out->owner_group = info_out->owner_group_buf;
6565
+        }
6666
     } else if (count == 1) {
6767
         if (parent_out)
6868
             *parent_out = dir;
6969
@@ -258,8 +263,12 @@ static int server_lookup(
7070
         if (i == count-1) {
7171
             if (target_out)
7272
                 *target_out = file;
7373
-            if (info_out)
7474
+            if (info_out) {
7575
+                /* fixme: need |copy_nfs41_file_info()| */
7676
                 memcpy(info_out, res->getattr[i].info, sizeof(nfs41_file_info));
7777
+                info_out->owner = info_out->owner_buf;
7878
+                info_out->owner_group = info_out->owner_group_buf;
7979
+            }
8080
         } else if (i == count-2) {
8181
             if (parent_out)
8282
                 *parent_out = file;
8383
diff --git a/daemon/name_cache.c b/daemon/name_cache.c
8484
index eaa0f36..2b7c257 100644
8585
--- a/daemon/name_cache.c
8686
+++ b/daemon/name_cache.c
8787
@@ -99,6 +99,8 @@ struct attr_cache_entry {
8888
     unsigned                type : 4;
8989
     unsigned                invalidated : 1;
9090
     unsigned                delegated : 1;
9191
+    char                    owner[NFS4_OPAQUE_LIMIT+1];
9292
+    char                    owner_group[NFS4_OPAQUE_LIMIT+1];
9393
 };
9494
 #define ATTR_ENTRY_SIZE sizeof(struct attr_cache_entry)
9595
9696
@@ -304,6 +306,14 @@ static void attr_cache_update(
9797
     if (info->attrmask.count >= 2) {
9898
         if (info->attrmask.arr[1] & FATTR4_WORD1_MODE)
9999
             entry->mode = info->mode;
100100
+        if (info->attrmask.arr[1] & FATTR4_WORD1_OWNER) {
101101
+            DASSERT(info->owner != NULL);
102102
+            (void)strcpy(entry->owner, info->owner);
103103
+        }
104104
+        if (info->attrmask.arr[1] & FATTR4_WORD1_OWNER_GROUP) {
105105
+            DASSERT(info->owner_group != NULL);
106106
+            (void)strcpy(entry->owner_group, info->owner_group);
107107
+        }
108108
         if (info->attrmask.arr[1] & FATTR4_WORD1_NUMLINKS)
109109
             entry->numlinks = info->numlinks;
110110
         if (info->attrmask.arr[1] & FATTR4_WORD1_TIME_ACCESS) {
111111
@@ -341,6 +351,14 @@ static void copy_attrs(
112112
     dst->type = src->type;
113113
     dst->numlinks = src->numlinks;
114114
     dst->mode = src->mode;
115115
+    DASSERT(src->owner != NULL);
116116
+//    if (dst->owner == NULL)
117117
+        dst->owner = dst->owner_buf;
118118
+    (void)strcpy(dst->owner, src->owner);
119119
+    DASSERT(src->owner_group != NULL);
120120
+//    if (dst->owner_group == NULL)
121121
+        dst->owner_group = dst->owner_group_buf;
122122
+    (void)strcpy(dst->owner_group, src->owner_group);
123123
     dst->fileid = src->fileid;
124124
     dst->hidden = src->hidden;
125125
     dst->system = src->system;
126126
@@ -353,7 +371,8 @@ static void copy_attrs(
127127
     dst->attrmask.arr[1] = FATTR4_WORD1_MODE
128128
         | FATTR4_WORD1_NUMLINKS | FATTR4_WORD1_TIME_ACCESS
129129
         | FATTR4_WORD1_TIME_CREATE | FATTR4_WORD1_TIME_MODIFY
130130
-        | FATTR4_WORD1_SYSTEM;
131131
+        | FATTR4_WORD1_SYSTEM
132132
+        | FATTR4_WORD1_OWNER | FATTR4_WORD1_OWNER_GROUP;
133133
 }
134134
135135
136136
@@ -401,7 +420,11 @@ struct nfs41_name_cache {
137137
 static __inline bool_t name_cache_enabled(
138138
     IN struct nfs41_name_cache *cache)
139139
 {
140140
+#if 0
141141
+    return 0; /* fixme: caching of owner/owner_group not supported yet */
142142
+#else
143143
     return cache->expiration > 0;
144144
+#endif
145145
 }
146146
147147
 static __inline void name_cache_entry_rename(
148148
diff --git a/daemon/nfs41_daemon.c b/daemon/nfs41_daemon.c
149149
index 42bfc6c..bc69fa8 100644
150150
--- a/daemon/nfs41_daemon.c
151151
+++ b/daemon/nfs41_daemon.c
152152
@@ -402,6 +402,7 @@ VOID ServiceStart(DWORD argc, LPTSTR *argv)
153153
 #ifdef NFS41_DRIVER_FEATURE_NAMESERVICE_CYGWIN
154154
     /* force enable for cygwin getent passwd/group testing */
155155
     cmd_args.ldap_enable = TRUE;
156156
+    DASSERT(cmd_args.ldap_enable == FALSE);
157157
 #endif /* NFS41_DRIVER_FEATURE_NAMESERVICE_CYGWIN */
158158
159159
     nfs41_server_list_init();
160160
diff --git a/daemon/nfs41_types.h b/daemon/nfs41_types.h
161161
index c5bad79..18a763a 100644
162162
--- a/daemon/nfs41_types.h
163163
+++ b/daemon/nfs41_types.h
164164
@@ -236,6 +236,10 @@ typedef struct __nfs41_file_info {
165165
     char                    *owner;
166166
     char                    *owner_group;
167167
     uint32_t                aclsupport;
168168
+
169169
+    /* Buffers */
170170
+    char owner_buf[NFS4_OPAQUE_LIMIT+1];
171171
+    char owner_group_buf[NFS4_OPAQUE_LIMIT+1];
172172
 } nfs41_file_info;
173173
174174
 #endif /* !__NFS41_DAEMON_TYPES_H__ */
175175
diff --git a/daemon/nfs41_xdr.c b/daemon/nfs41_xdr.c
176176
index 176b613..67c9bf6 100644
177177
--- a/daemon/nfs41_xdr.c
178178
+++ b/daemon/nfs41_xdr.c
179179
@@ -1802,19 +1802,33 @@ static bool_t decode_file_attrs(
180180
                 return FALSE;
181181
         }
182182
         if (attrs->attrmask.arr[1] & FATTR4_WORD1_OWNER) {
183183
-            char *ptr = &info->owner[0];
184184
+            if (info->owner == NULL)
185185
+                info->owner = info->owner_buf;
186186
+
187187
+            char *ptr = info->owner;
188188
             uint32_t owner_len;
189189
             if (!xdr_bytes(xdr, &ptr, &owner_len,
190190
-                            NFS4_OPAQUE_LIMIT))
191191
+                            NFS4_OPAQUE_LIMIT)) {
192192
+                info->owner = NULL;
193193
                 return FALSE;
194194
+            }
195195
+            DASSERT(owner_len > 0);
196196
+            DASSERT(owner_len < sizeof(info->owner_group_buf));
197197
             info->owner[owner_len] = '\0';
198198
         }
199199
         if (attrs->attrmask.arr[1] & FATTR4_WORD1_OWNER_GROUP) {
200200
-            char *ptr = &info->owner_group[0];
201201
+            if (info->owner_group == NULL)
202202
+                info->owner_group = info->owner_group_buf;
203203
+
204204
+            char *ptr = info->owner_group;
205205
             uint32_t owner_group_len;
206206
             if (!xdr_bytes(xdr, &ptr, &owner_group_len,
207207
-                            NFS4_OPAQUE_LIMIT))
208208
+                            NFS4_OPAQUE_LIMIT)) {
209209
+                info->owner_group = NULL;
210210
                 return FALSE;
211211
+            }
212212
+            DASSERT(owner_group_len > 0);
213213
+            DASSERT(owner_group_len < sizeof(info->owner_group_buf));
214214
             info->owner_group[owner_group_len] = '\0';
215215
         }
216216
         if (attrs->attrmask.arr[1] & FATTR4_WORD1_SPACE_AVAIL) {
217217
diff --git a/daemon/open.c b/daemon/open.c
218218
index 13e82b2..f1d7f20 100644
219219
--- a/daemon/open.c
220220
+++ b/daemon/open.c
221221
@@ -629,7 +629,7 @@ static int handle_open(void *daemon_context, nfs41_upcall *upcall)
222222
         status = NO_ERROR;
223223
     } else if (args->symlink.len) {
224224
         /* handle cygwin symlinks */
225225
-        nfs41_file_info createattrs;
226226
+        nfs41_file_info createattrs = { 0 };
227227
         createattrs.attrmask.count = 2;
228228
         createattrs.attrmask.arr[0] = 0;
229229
         createattrs.attrmask.arr[1] = FATTR4_WORD1_MODE;
230230
@@ -663,33 +663,21 @@ static int handle_open(void *daemon_context, nfs41_upcall *upcall)
231231
         args->changeattr = info.change;
232232
233233
 #ifdef NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES
234234
-        bitmap4 og_attr_request = { 0 };
235235
-        nfs41_file_info og_info = { 0 };
236236
-        char owner[NFS4_OPAQUE_LIMIT], group[NFS4_OPAQUE_LIMIT];
237237
-        nfsacl41 acl = { 0 };
238238
-
239239
-        /*
240240
-         * gisburn:
241241
-         * 1. We should cache owner/group information
242242
-         * 2. We should always ask for
243243
-         * FATTR4_WORD1_OWNER | FATTR4_WORD1_OWNER_GROUP with the other
244244
-         * attributes
245245
-         */
246246
-        og_attr_request.count = 2;
247247
-        og_attr_request.arr[1] = FATTR4_WORD1_OWNER | FATTR4_WORD1_OWNER_GROUP;
248248
-        og_info.owner = owner;
249249
-        og_info.owner_group = group;
250250
-        status = nfs41_getattr(state->session, &state->file, &og_attr_request, &og_info);
251251
-        if (status) {
252252
-            eprintf("get_stat_data: nfs41_cached_getattr() failed with %d\n",
253253
-            status);
254254
-        }
255255
-
256256
+        char owner[NFS4_OPAQUE_LIMIT], owner_group[NFS4_OPAQUE_LIMIT];
257257
         uid_t map_uid = -1;
258258
         gid_t gid_dummy = -1;
259259
         gid_t map_gid = -1;
260260
         char *at_ch; /* pointer to '@' */
261261
262262
+        DASSERT((info.attrmask.arr[1] & FATTR4_WORD1_OWNER) != 0);
263263
+        DASSERT((info.attrmask.arr[1] & FATTR4_WORD1_OWNER_GROUP) != 0);
264264
+        DASSERT(info.owner != NULL);
265265
+        DASSERT(info.owner_group != NULL);
266266
+        DASSERT(info.owner == info.owner_buf);
267267
+        DASSERT(info.owner_group == info.owner_group_buf);
268268
+        (void)strcpy(owner, info.owner?info.owner:"<FIXME_OWNER>");
269269
+        (void)strcpy(owner_group, info.owner_group?info.owner_group:"<FIXME_GROUP>");
270270
+
271271
         /*
272272
          * Map owner to local uid
273273
          *
274274
@@ -697,12 +685,12 @@ static int handle_open(void *daemon_context, nfs41_upcall *upcall)
275275
          *  ("gisburn") or username@domain ("gisburn@sun.com")
276276
          */
277277
         /* stomp over '@' */
278278
-        if (at_ch = strchr(og_info.owner, '@'))
279279
+        if (at_ch = strchr(owner, '@'))
280280
             *at_ch = '\0';
281281
282282
         if (nfs41_idmap_name_to_ids(
283283
             nfs41dg->idmapper,
284284
-            og_info.owner,
285285
+            owner,
286286
             &map_uid,
287287
             &gid_dummy) == 0) {
288288
              args->owner_local_uid = map_uid;
289289
@@ -711,7 +699,7 @@ static int handle_open(void *daemon_context, nfs41_upcall *upcall)
290290
             args->owner_local_uid = NFS_USER_NOBODY_UID;
291291
             eprintf("get_stat_data: "
292292
                 "no username mapping for '%s', fake uid=%d\n",
293293
-                og_info.owner, args->owner_local_uid);
294294
+                owner, args->owner_local_uid);
295295
         }
296296
297297
         /*
298298
@@ -721,12 +709,12 @@ static int handle_open(void *daemon_context, nfs41_upcall *upcall)
299299
          * ("gisgrp") or username@domain ("gisgrp@sun.com")
300300
          */
301301
         /* stomp over '@' */
302302
-        if (at_ch = strchr(og_info.owner_group, '@'))
303303
+        if (at_ch = strchr(owner_group, '@'))
304304
             *at_ch = '\0';
305305
306306
         if (nfs41_idmap_group_to_gid(
307307
             nfs41dg->idmapper,
308308
-            og_info.owner_group,
309309
+            owner_group,
310310
             &map_gid) == 0) {
311311
             args->owner_group_local_gid = map_gid;
312312
         }
313313
@@ -734,12 +722,12 @@ static int handle_open(void *daemon_context, nfs41_upcall *upcall)
314314
             args->owner_group_local_gid = NFS_GROUP_NOGROUP_GID;
315315
             eprintf("get_stat_data: "
316316
                 "no group mapping for '%s', fake gid=%d\n",
317317
-                og_info.owner_group, args->owner_group_local_gid);
318318
+                owner_group, args->owner_group_local_gid);
319319
         }
320320
321321
         dprintf(1, "handle_open: stat: owner=%u/'%s', owner_group=%u/'%s'\n",
322322
-            (unsigned int)args->owner_local_uid, og_info.owner,
323323
-            (unsigned int)args->owner_group_local_gid, og_info.owner_group);
324324
+            (unsigned int)args->owner_local_uid, owner,
325325
+            (unsigned int)args->owner_group_local_gid, owner_group);
326326
 #endif /* NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES */
327327
     } else {
328328
         nfs41_file_info createattrs = { 0 };
329329
diff --git a/sys/nfs41_build_features.h b/sys/nfs41_build_features.h
330330
index 93ee7a9..d43334a 100644
331331
--- a/sys/nfs41_build_features.h
332332
+++ b/sys/nfs41_build_features.h
333333
@@ -32,19 +32,19 @@
334334
 /*
335335
  * NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES - return local uid/gid values
336336
  */
337337
-// #define NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES 1
338338
+#define NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES 1
339339
340340
 /*
341341
  * NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID - give NFS
342342
  * files which do not map to a local account a SID in the
343343
  * Unix_User+x/Unix_Group+x range
344344
  */
345345
-// #define NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID 1
346346
+#define NFS41_DRIVER_FEATURE_MAP_UNMAPPED_USER_TO_UNIXUSER_SID 1
347347
348348
 /*
349349
  * NFS41_DRIVER_FEATURE_NAMESERVICE_CYGWIN - use Cygwin /usr/bin/getent
350350
  * as "name service"
351351
  */
352352
-// #define NFS41_DRIVER_FEATURE_NAMESERVICE_CYGWIN 1
353353
+#define NFS41_DRIVER_FEATURE_NAMESERVICE_CYGWIN 1
354354
355355
 #endif /* !_NFS41_DRIVER_BUILDFEATURES_ */
356356

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