pastebin - collaborative debugging tool
rovema.kpaste.net RSS

Difference between
modified post 7760a1427 by Anonymous on Mon 9th Oct 2023 08:17
original post cf by Anonymous on Sat 7th Oct 2023 10:36
Download diff
Show old version | new version | both versions

    
1-
# msnfs42client: Test for Cygwin/SFU uid/gid in nfs3_attrs
1+
diff --git a/daemon/open.c b/daemon/open.c
2-
diff --git a/sys/nfs41_driver.c b/sys/nfs41_driver.c
2+
index c7bd412..aee931c 100644
3-
index 6a8061d..2bc730d 100644
3+
--- a/daemon/open.c
4-
--- a/sys/nfs41_driver.c
4+
+++ b/daemon/open.c
5-
+++ b/sys/nfs41_driver.c
5+
@@ -295,6 +295,12 @@ static int parse_open(unsigned char *buffer, uint32_t length, nfs41_upcall *upca
6-
@@ -4502,6 +4502,8 @@ void create_nfs3_attrs(
6+
     if (status) goto out;
7-
     else
7+
     status = safe_read(&buffer, &length, &args->mode, sizeof(DWORD));
8-
         attrs->type = NF3REG;
8+
     if (status) goto out;
9-
     attrs->mode = nfs41_fcb->mode;
9+
+#if 1
10-
+    attrs->uid = 72488;
10+
+    status = safe_read(&buffer, &length, &args->owner_cygwin_uid, sizeof(DWORD));
11-
+    attrs->gid = 21984;
11+
+    if (status) goto out;
12-
     attrs->nlink = nfs41_fcb->StandardInfo.NumberOfLinks;
12+
+    status = safe_read(&buffer, &length, &args->owner_group_cygwin_gid, sizeof(DWORD));
13-
     attrs->size.QuadPart = attrs->used.QuadPart =
13+
+    if (status) goto out;
14-
         nfs41_fcb->StandardInfo.EndOfFile.QuadPart;
14+
+#endif
15-
# results in:
15+
     status = safe_read(&buffer, &length, &args->srv_open, sizeof(HANDLE));
16-
# roland_mainz@winkrakra1 ~/work/kofemann_msnfs41/ms-nfs41-client
16+
     if (status) goto out;
17-
# $ ls -l /cygdrive/h/tmp/a.exe
17+
     status = parse_abs_path(&buffer, &length, &args->symlink);
18-
# -rwxr-xr-x 1 Unix_User+72488 Unix_Group+21984 93684 Oct  4 07:27 /cygdrive/h/tmp/a.exe
18+
@@ -305,9 +311,16 @@ static int parse_open(unsigned char *buffer, uint32_t length, nfs41_upcall *upca
19-
19+
     dprintf(1, "parsing NFS41_OPEN: filename='%s' access mask=%d "
20-
20+
         "access mode=%d\n\tfile attrs=0x%x create attrs=0x%x "
21-
21+
         "(kernel) disposition=%d\n\topen_owner_id=%d mode=%o "
22-
22+
+#if 1
23-
23+
+        "owner_cygwin_uid=%lu owner_group_cygwin_gid=%lu "
24-
24+
+#endif
25-
25+
         "srv_open=%p symlink=%s ea=%p\n", args->path, args->access_mask,
26-
26+
         args->access_mode, args->file_attrs, args->create_opts,
27-
27+
-        args->disposition, args->open_owner_id, args->mode, args->srv_open,
28-
28+
+        args->disposition, args->open_owner_id, args->mode,
29-
29+
+#if 1
30-
30+
+        (unsigned long)args->owner_cygwin_uid, (unsigned long)args->owner_group_cygwin_gid,
31-
31+
+#endif
32-
32+
+        args->srv_open,
33-
33+
         args->symlink.path, args->ea);
34-
34+
     print_disposition(2, args->disposition);
35-
35+
     print_access_mask(2, args->access_mask);
36-
36+
@@ -644,6 +657,31 @@ static int handle_open(nfs41_upcall *upcall)
37-
37+
         nfs_to_standard_info(&info, &args->std_info);
38-
38+
         args->mode = info.mode;
39-
39+
         args->changeattr = info.change;
40-
40+
+
41-
41+
+#if 1
42-
42+
+        bitmap4 og_attr_request = { 0 };
43-
43+
+        nfs41_file_info og_info = { 0 };
44-
44+
+        char owner[NFS4_OPAQUE_LIMIT], group[NFS4_OPAQUE_LIMIT];
45-
45+
+        nfsacl41 acl = { 0 };
46-
46+
+
47-
47+
+        /* gisburn: need to cache owner/group information */
48-
48+
+        og_attr_request.count = 2;
49-
49+
+        og_attr_request.arr[1] = FATTR4_WORD1_OWNER | FATTR4_WORD1_OWNER_GROUP;
50-
50+
+        og_info.owner = owner;
51-
51+
+        og_info.owner_group = group;
52-
52+
+        status = nfs41_getattr(state->session, &state->file, &og_attr_request, &og_info);
53-
53+
+        if (status) {
54-
54+
+            eprintf("get_stat_data: nfs41_cached_getattr() failed with %d\n",
55-
55+
+            status);
56-
56+
+        }
57-
57+
+
58-
58+
+        args->owner_cygwin_uid = atol(og_info.owner);
59-
59+
+        args->owner_group_cygwin_gid = atol(og_info.owner_group);
60-
60+
+
61-
61+
+	dprintf(1, "/usr/bin/stat: owner=%lu/'%s', owner_group=%lu/'%s'\n",
62-
62+
+            (unsigned long)args->owner_cygwin_uid, og_info.owner,
63-
63+
+            (unsigned long)args->owner_group_cygwin_gid, og_info.owner_group);
64-
64+
+#endif
65-
65+
     } else {
66-
66+
         nfs41_file_info createattrs = { 0 };
67-
67+
         uint32_t create = 0, createhowmode = 0, lookup_status = status;
68-
68+
@@ -753,6 +791,12 @@ static int marshall_open(unsigned char *buffer, uint32_t *length, nfs41_upcall *
69-
69+
     if (status) goto out;
70-
70+
     status = safe_write(&buffer, length, &args->mode, sizeof(args->mode));
71-
71+
     if (status) goto out;
72-
72+
+#if 1
73-
73+
+    status = safe_write(&buffer, length, &args->owner_cygwin_uid, sizeof(args->owner_cygwin_uid));
74-
74+
+    if (status) goto out;
75-
75+
+    status = safe_write(&buffer, length, &args->owner_group_cygwin_gid, sizeof(args->owner_group_cygwin_gid));
76-
76+
+    if (status) goto out;
77-
77+
+#endif
78-
78+
     status = safe_write(&buffer, length, &args->changeattr, sizeof(args->changeattr));
79-
79+
     if (status) goto out;
80-
80+
     status = safe_write(&buffer, length, &args->deleg_type, sizeof(args->deleg_type));
81-
81+
diff --git a/daemon/upcall.h b/daemon/upcall.h
82-
82+
index d224a6d..99149be 100644
83-
83+
--- a/daemon/upcall.h
84-
84+
+++ b/daemon/upcall.h
85-
85+
@@ -50,6 +50,8 @@ typedef struct __open_upcall_args {
86-
86+
     ULONG create_opts;
87-
87+
     LONG open_owner_id;
88-
88+
     DWORD mode;
89-
89+
+    DWORD owner_cygwin_uid;         /* owner mapped into local uid */
90-
90+
+    DWORD owner_group_cygwin_gid;   /* owner group mapped into local gid */
91-
91+
     ULONGLONG changeattr;
92-
92+
     HANDLE srv_open;
93-
93+
     DWORD deleg_type;
94-
94+
diff --git a/sys/nfs41_driver.c b/sys/nfs41_driver.c
95-
95+
index 6a8061d..7deb9ec 100644
96-
96+
--- a/sys/nfs41_driver.c
97-
97+
+++ b/sys/nfs41_driver.c
98-
98+
@@ -200,6 +200,8 @@ typedef struct _updowncall_entry {
99-
99+
             ULONG cattrs;
100-
100+
             LONG open_owner_id;
101-
101+
             DWORD mode;
102-
102+
+	    DWORD owner_cygwin_uid;
103-
103+
+	    DWORD owner_group_cygwin_gid;
104-
104+
             HANDLE srv_open;
105-
105+
             DWORD deleg_type;
106-
106+
             BOOLEAN symlink_embedded;
107-
107+
@@ -385,6 +387,8 @@ typedef struct _NFS41_FCB {
108-
108+
     BOOLEAN                 Renamed;
109-
109+
     BOOLEAN                 DeletePending;
110-
110+
     DWORD                   mode;
111-
111+
+    DWORD                   owner_cygwin_uid;       /* owner mapped into local uid */
112-
112+
+    DWORD                   owner_group_cygwin_gid; /* owner group mapped into local gid */
113-
113+
     ULONGLONG               changeattr;
114-
114+
 } NFS41_FCB, *PNFS41_FCB;
115-
115+
 #define NFS41GetFcbExtension(pFcb)      \
116-
116+
@@ -667,7 +671,11 @@ NTSTATUS marshal_nfs41_open(
117-
117+
     else tmp += *len;
118118
119-
119+
     header_len = *len + length_as_utf8(entry->filename) +
120-
120+
-        7 * sizeof(ULONG) + 2 * sizeof(HANDLE) +
121-
121+
+        7 * sizeof(ULONG) +
122-
122+
+#if 1
123-
123+
+        2 * sizeof(DWORD) +
124-
124+
+#endif
125-
125+
+        2 * sizeof(HANDLE) +
126-
126+
         length_as_utf8(&entry->u.Open.symlink);
127-
127+
     if (header_len > buf_len) {
128-
128+
         status = STATUS_INSUFFICIENT_RESOURCES;
129-
129+
@@ -692,6 +700,12 @@ NTSTATUS marshal_nfs41_open(
130-
130+
     tmp += sizeof(entry->u.Open.open_owner_id);
131-
131+
     RtlCopyMemory(tmp, &entry->u.Open.mode, sizeof(DWORD));
132-
132+
     tmp += sizeof(DWORD);
133-
133+
+#if 1
134-
134+
+    RtlCopyMemory(tmp, &entry->u.Open.owner_cygwin_uid, sizeof(DWORD));
135-
135+
+    tmp += sizeof(DWORD);
136-
136+
+    RtlCopyMemory(tmp, &entry->u.Open.owner_group_cygwin_gid, sizeof(DWORD));
137-
137+
+    tmp += sizeof(DWORD);
138-
138+
+#endif
139-
139+
     RtlCopyMemory(tmp, &entry->u.Open.srv_open, sizeof(HANDLE));
140-
140+
     tmp += sizeof(HANDLE);
141-
141+
     status = marshall_unicode_as_utf8(&tmp, &entry->u.Open.symlink);
142-
142+
@@ -718,10 +732,17 @@ NTSTATUS marshal_nfs41_open(
143143
144-
144+
 #ifdef DEBUG_MARSHAL_DETAIL
145-
145+
     DbgP("marshal_nfs41_open: name=%wZ mask=0x%x access=0x%x attrs=0x%x "
146-
146+
-         "opts=0x%x dispo=0x%x open_owner_id=0x%x mode=%o srv_open=%p ea=%p\n",
147-
147+
+         "opts=0x%x dispo=0x%x open_owner_id=0x%x mode=%o "
148-
148+
+#if 1
149-
149+
+	 "owner_cygwin_uid=%lu owner_group_cygwin_gid=%lu "
150-
150+
+#endif
151-
151+
+	 "srv_open=%p ea=%p\n",
152-
152+
          entry->filename, entry->u.Open.access_mask,
153-
153+
          entry->u.Open.access_mode, entry->u.Open.attrs, entry->u.Open.copts,
154-
154+
          entry->u.Open.disp, entry->u.Open.open_owner_id, entry->u.Open.mode,
155-
155+
+#if 1
156-
156+
+	 entry->u.Open.owner_cygwin_uid,entry->u.Open.owner_group_cygwin_gid,
157-
157+
+#endif
158-
158+
          entry->u.Open.srv_open, entry->u.Open.EaBuffer);
159-
159+
 #endif
160-
160+
 out:
161-
161+
@@ -1647,6 +1668,12 @@ NTSTATUS unmarshal_nfs41_open(
162-
162+
     *buf += sizeof(HANDLE);
163-
163+
     RtlCopyMemory(&cur->u.Open.mode, *buf, sizeof(DWORD));
164-
164+
     *buf += sizeof(DWORD);
165-
165+
+#if 1
166-
166+
+    RtlCopyMemory(&cur->u.Open.owner_cygwin_uid, *buf, sizeof(DWORD));
167-
167+
+    *buf += sizeof(DWORD);
168-
168+
+    RtlCopyMemory(&cur->u.Open.owner_group_cygwin_gid, *buf, sizeof(DWORD));
169-
169+
+    *buf += sizeof(DWORD);
170-
170+
+#endif
171-
171+
     RtlCopyMemory(&cur->ChangeTime, *buf, sizeof(ULONGLONG));
172-
172+
     *buf += sizeof(ULONGLONG);
173-
173+
     RtlCopyMemory(&cur->u.Open.deleg_type, *buf, sizeof(DWORD));
174-
174+
@@ -1673,8 +1700,15 @@ NTSTATUS unmarshal_nfs41_open(
175-
175+
 #endif
176-
176+
     }
177-
177+
 #ifdef DEBUG_MARSHAL_DETAIL
178-
178+
-    DbgP("unmarshal_nfs41_open: open_state 0x%x mode %o changeattr %llu "
179-
179+
+    DbgP("unmarshal_nfs41_open: open_state 0x%x mode %o "
180-
180+
+#if 1
181-
181+
+        "owner_cygwin_uid %u owner_group_cygwin_gid %u "
182-
182+
+#endif
183-
183+
+        "changeattr %llu "
184-
184+
         "deleg_type %d\n", cur->open_state, cur->u.Open.mode,
185-
185+
+#if 1
186-
186+
+        cur->u.Open.owner_cygwin_uid, cur->u.Open.owner_group_cygwin_gid,
187-
187+
+#endif
188-
188+
         cur->ChangeTime, cur->u.Open.deleg_type);
189-
189+
 #endif
190-
190+
 out:
191-
191+
@@ -3754,6 +3788,10 @@ retry_on_link:
192-
192+
         RtlCopyMemory(&nfs41_fcb->StandardInfo, &entry->u.Open.sinfo,
193-
193+
             sizeof(entry->u.Open.sinfo));
194-
194+
         nfs41_fcb->mode = entry->u.Open.mode;
195-
195+
+#if 1
196-
196+
+	nfs41_fcb->owner_cygwin_uid = entry->u.Open.owner_cygwin_uid;
197-
197+
+	nfs41_fcb->owner_group_cygwin_gid = entry->u.Open.owner_group_cygwin_gid;
198-
198+
+#endif
199-
199+
         nfs41_fcb->changeattr = entry->ChangeTime;
200-
200+
         if (((params->CreateOptions & FILE_DELETE_ON_CLOSE) &&
201-
201+
                 !pVNetRootContext->read_only) || oldDeletePending)
202-
202+
@@ -4502,6 +4540,8 @@ void create_nfs3_attrs(
203-
203+
     else
204-
204+
         attrs->type = NF3REG;
205-
205+
     attrs->mode = nfs41_fcb->mode;
206-
206+
+    attrs->uid = nfs41_fcb->owner_cygwin_uid;
207-
207+
+    attrs->gid = nfs41_fcb->owner_group_cygwin_gid;
208-
208+
     attrs->nlink = nfs41_fcb->StandardInfo.NumberOfLinks;
209-
209+
     attrs->size.QuadPart = attrs->used.QuadPart =
210-
210+
         nfs41_fcb->StandardInfo.EndOfFile.QuadPart;
211211

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